Community
Participate
Working Groups
Spinner has a text value and a selection value. While the selection is always a number within the range of valid values of the spinner, the text can be any number, represented as a string. For example, typing "200" into a spinner that has 100 as the max value results in 100 as selection, but "200" as text. In RWT both would be 100. Furthermore, Selection events are fired when actually only the Modify event should be fired, e.g. when changing from 100 to 1000.
I've attached a snippet demonstrating the difference in behaviour of Spinner.getText() during a modify event in RWT vs SWT. The SWT behaviour allowing an out of range value to be detected during modification was introduced in bug 186634.
The Spinner.getText() snippet can also be used to observe that modification events are fired whenever a key is typed in the spinner (regardless of effect). e.g. left arrow, right arrow and alt all produce modification events in RWT, but not in SWT.
To clarify part of the original report, the text in a Spinner can be any value (including non-numeric values), and will only modify the selection if it is within the range defined by the Spinner. When a Spinner loses focus, the text is reset to the selection (i.e. it will change to match the selection if it was not a number or out of range). The detection of invalid/out of range text is important to provide UI affordance that an invalid input will not be persisted (e.g. disabling a save button or displaying an RCP Form error).
Created attachment 228103 [details] Snippet demonstrating invalid getText during modify event
*** Bug 421265 has been marked as a duplicate of this bug. ***