summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
diff options
context:
space:
mode:
authorSteve Northover <steve>2005-04-26 16:23:31 +0000
committerSteve Northover <steve>2005-04-26 16:23:31 +0000
commit6389a96d37d1591f2c74eb9b6d6103f3024dc814 (patch)
tree080cb0c48876580b1ed95eac2edb4c2b9e38fac6 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
parent1c5494d189a1666acb8f44f03c824d6f71b39326 (diff)
downloadeclipse.platform.swt-6389a96d37d1591f2c74eb9b6d6103f3024dc814.tar.gz
eclipse.platform.swt-6389a96d37d1591f2c74eb9b6d6103f3024dc814.tar.xz
eclipse.platform.swt-6389a96d37d1591f2c74eb9b6d6103f3024dc814.zip
86214
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
index 9ead1485dd..1af2ebb56c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
@@ -518,13 +518,27 @@ int /*long*/ gtk_insert_text (int /*long*/ widget, int /*long*/ new_text, int /*
int /*long*/ ptr = OS.gtk_entry_get_text (handle);
pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1);
}
- String newText = verifyText (oldText, pos [0], pos [0]); //WRONG POSITION
+ int [] oldStart = new int [1], oldEnd = new int [1];
+ OS.gtk_editable_get_selection_bounds (handle, oldStart, oldEnd);
+ String newText = verifyText (oldText, pos [0], pos [0]);
+ final int [] newStart = new int [1], newEnd = new int [1];
+ OS.gtk_editable_get_selection_bounds (handle, newStart, newEnd);
+ boolean newSelection = oldStart [0] != newStart [0] || oldEnd [0] != newEnd [0];
+ if (newSelection) {
+ if (newText == null) newText = "";
+ pos [0] = newEnd [0];
+ }
if (newText == null) {
OS.g_signal_stop_emission_by_name (handle, OS.insert_text);
} else {
- if (newText != oldText) {
+ if (newText != oldText || newSelection) {
byte [] buffer2 = Converter.wcsToMbcs (null, newText, false);
OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+ if (newSelection) {
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ OS.gtk_editable_delete_selection (handle);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ }
OS.gtk_editable_insert_text (handle, buffer2, buffer2.length, pos);
OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
OS.g_signal_stop_emission_by_name (handle, OS.insert_text);