Nadya Posted June 22, 2020 Share Posted June 22, 2020 Hi! I have a TUniSpinEdit control on form. It is used to choose a year. So, first of all, I need this control to allow integer values only (without floating part). And I need to set the value increment to 1. Because while I press and hold an arrow of my control, the value increasing/decreasing continiously. Thank's in advance for help! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 22, 2020 Share Posted June 22, 2020 Hi, 52 minutes ago, Nadya said: I have a TUniSpinEdit control on form. It is used to choose a year. So, first of all, I need this control to allow integer values only (without floating part). UniSpinEdit.ClientEvents.UniEvents -> function beforeInit(sender, config) { config.allowDecimals=false; config.allowExponential=false; } UniSpinEdit.ClientEvents.ExtEvents -> function keydown(sender, e, eOpts) { if (e.keyCode == 110 || e.keyCode == 188) { e.stopEvent(); } } 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 22, 2020 Share Posted June 22, 2020 54 minutes ago, Nadya said: And I need to set the value increment to 1. Because while I press and hold an arrow of my control, the value increasing/decreasing continiously. ? Quote Link to comment Share on other sites More sharing options...
Nadya Posted June 23, 2020 Author Share Posted June 23, 2020 14 hours ago, Sherzod said: UniSpinEdit.ClientEvents.UniEvents -> function beforeInit(sender, config) { config.allowDecimals=false; config.allowExponential=false; } UniSpinEdit.ClientEvents.ExtEvents -> function keydown(sender, e, eOpts) { if (e.keyCode == 110 || e.keyCode == 188) { e.stopEvent(); } } I added this code to Clients events of my spinedit named "seYear". Now if I manually change text in the spinedit, for example, 2020.2, in debugger seYear.Value = 2020, if I print 2020.7, seYear.Value = 2021. Looks like value is just rounded. Would by great if component wil not allow event print decimal values, maybe something like editmask or so SpinEdit with decimal point 14 hours ago, Sherzod said: 15 hours ago, Nadya said: And I need to set the value increment to 1. Because while I press and hold an arrow of my control, the value increasing/decreasing continiously. ? Sorry maybe I explained wrong. Every time seYear value is changed I refresh data for selected year. So if I briefly click on arrow key (up for example) of spinedit - it's ok, data refreshed for next selected year value. But If I press and hold arrow key of spinedit for some time, values in it change one by one, until max value (2050) is reached. And for every value from 2020 to 2050 refreshing of data happens. Mayby there is some way to disable this behaviour? I understand that I'm doing something wrong but can't see what exactly :-) Thank for your attention and help! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted June 23, 2020 Share Posted June 23, 2020 1 hour ago, Nadya said: Sorry maybe I explained wrong. Every time seYear value is changed I refresh data for selected year. So if I briefly click on arrow key (up for example) of spinedit - it's ok, data refreshed for next selected year value. But If I press and hold arrow key of spinedit for some time, values in it change one by one, until max value (2050) is reached. And for every value from 2020 to 2050 refreshing of data happens. Mayby there is some way to disable this behaviour? Hi Nadya, Use this config: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniSpinEdit1.JSInterface.JSConfig('repeatTriggerClick', [False]); end; 1 Quote Link to comment Share on other sites More sharing options...
Nadya Posted June 23, 2020 Author Share Posted June 23, 2020 1 hour ago, Sherzod said: Use this config: procedure TMainForm.UniFormCreate(Sender: TObject); begin UniSpinEdit1.JSInterface.JSConfig('repeatTriggerClick', [False]); end; It's brilliant, that's exactly what i need! Thank you!!! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.