diff options
author | Felipe Heidrich <fheidric> | 2008-02-28 23:46:43 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2008-02-28 23:46:43 +0000 |
commit | 4991353da3877d1e51a2ded37b3599a6a62e982e (patch) | |
tree | 209ee0c6ca5cac3f01073dcecfd175001ecad26a /bundles/org.eclipse.swt/Eclipse SWT | |
parent | f4aa2f1fc5a803b4e9294dbb434f85b533615d06 (diff) | |
download | eclipse.platform.swt-4991353da3877d1e51a2ded37b3599a6a62e982e.tar.gz eclipse.platform.swt-4991353da3877d1e51a2ded37b3599a6a62e982e.tar.xz eclipse.platform.swt-4991353da3877d1e51a2ded37b3599a6a62e982e.zip |
Bug 186634 Spinner: getSelection() during modify event should provide a mechanism to detect if the user has typed a value that is out of range
Bug 214030 setTextLimit for SWT Spinner widget
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Spinner.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Spinner.java index d706f1b3ee..9112a87e5a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Spinner.java @@ -40,6 +40,20 @@ public class Spinner extends Composite { int textHandle, upHandle, downHandle; int increment, pageIncrement, digits, max, min, value; + /** + * the operating system limit for the number of characters + * that the text field in an instance of this class can hold + */ + public static final int LIMIT; + + /* + * These values can be different on different platforms. + * Therefore they are not initialized in the declaration + * to stop the compiler from inlining. + */ + static { + LIMIT = 0x7FFFFFFF; + } /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. @@ -458,6 +472,19 @@ int getSelectionText (boolean [] parseFail) { return -1; } +public String getText () { + checkWidget (); + int text = OS.TextBox_Text (textHandle); + String string = createJavaString (text); + OS.GCHandle_Free (text); + return string; +} + +public int getTextLimit () { + checkWidget (); + return OS.TextBox_MaxLength (textHandle); +} + void HandleDownClick (int sender, int e) { if (!checkEvent (e)) return; updateSelection (-increment); @@ -813,6 +840,12 @@ void setSelection (int value, boolean setPos, boolean setText, boolean notify) { if (notify) postEvent (SWT.Selection); } +public void setTextLimit (int limit) { + checkWidget (); + if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO); + OS.TextBox_MaxLength (textHandle, limit); +} + /** * Sets the receiver's selection, minimum value, maximum * value, digits, increment and page increment all at once. |