Project: SWT
Bug 94065 Spinner does't update internal state during text modify
Reported: 2005-05-08 16:05:08 | Status: resolved wontfix

The following code from Spinner.sendKeyEvent does not seem to be correct: default: /* Tab and other characters */ if (key != '\t' && key < 0x20) return true; oldText = new String (new char [] {key}); break; } String newText = verifyText (oldText, start [0], end [0], event); if (newText == null) return false; if (newText == oldText) return true; TCHAR buffer = new TCHAR (getCodePage (), newText, true); OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], end [0]); OS.SendMessage (hwndText, OS.EM_REPLACESEL, 0, buffer); Consider a test when the Spiner is set to 1, the whole contents is selected, and user presses key 2. The code will exit at "if (newText == oldText) return true;" since oldText is set to "2" by "oldText = new String (new char [] {key});" Similar problem affects wmClipboard method too: if (newText != null && !newText.equals (oldText)) { oldText = newText; newText = verifyText (newText, start [0], end [0], null); if (newText == null) return LRESULT.ZERO; if (!newText.equals (oldText)) { oldText is almost always the same as newText since it was explicitly assigned by "oldText = newText;".

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java