http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg40029.html
Spinner tempSpinner = new Spinner(parent, SWT.WRAP);
tempSpinner.setLocation(10 ,10);
tempSpinner.setSize(100, 20);
tempSpinner.setMinimum(0);
tempSpinner.setMaximum(12);
tempSpinner.setSelection(6);
tempSpinner.setFocus();
// tempSpinner如何实现Text类似SelectAll的功能呢?
public void focusGained(FocusEvent e) { if(e.getSource() instanceof Spinner){ Spinner spinner = (Spinner)e.getSource(); int hwnd = OS.GetWindow (spinner.handle, OS.GW_CHILD); int hwndText = OS.GetWindow (hwnd, OS.GW_HWNDNEXT); OS.SendMessage (hwndText, OS.EM_SETSEL, 0, -1); } }
上面的就是解决方法, 难道非要去调用OS来通知Spinner进行全选吗?