diff options
author | Carolyn MacLeod <carolyn> | 2006-11-02 07:42:26 +0000 |
---|---|---|
committer | Carolyn MacLeod <carolyn> | 2006-11-02 07:42:26 +0000 |
commit | 25922dad9087dac2f5edd469969f6042bf02cc9e (patch) | |
tree | 3d90aef793279a19b0b6c2cf5119d31ba281f746 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java | |
parent | f3f946ee0735fc5403aab619e562bdb79e271c86 (diff) | |
download | eclipse.platform.swt-25922dad9087dac2f5edd469969f6042bf02cc9e.tar.gz eclipse.platform.swt-25922dad9087dac2f5edd469969f6042bf02cc9e.tar.xz eclipse.platform.swt-25922dad9087dac2f5edd469969f6042bf02cc9e.zip |
don't rely on getSelectionText in verify (work around gtk problem)
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java index c96410fe7e..f457715386 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java @@ -170,7 +170,12 @@ void commitCurrentField() { if (characterCount > 0) { characterCount = 0; int fieldName = fieldNames[currentField]; - int newValue = unformattedIntValue(fieldName, text.getSelectionText(), characterCount == 0, calendar.getActualMaximum(fieldName)); + int start = fieldIndices[currentField].x; + int end = fieldIndices[currentField].y; + String value = text.getText(start, end - 1); + int s = value.lastIndexOf(' '); + if (s != -1) value = value.substring(s + 1); + int newValue = unformattedIntValue(fieldName, value, characterCount == 0, calendar.getActualMaximum(fieldName)); if (newValue != -1) setTextField(fieldName, newValue, true, true); } } @@ -432,7 +437,15 @@ void onVerify(Event event) { return; } if (characterCount > 0) { - newText = "" + text.getSelectionText() + newText; + try { + Integer.parseInt(newText); + } catch (NumberFormatException ex) { + return; + } + String value = text.getText(start, end - 1); + int s = value.lastIndexOf(' '); + if (s != -1) value = value.substring(s + 1); + newText = "" + value + newText; } int newTextLength = newText.length(); boolean first = characterCount == 0; |