summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-05-10 09:51:45 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-05-10 09:52:23 -0400
commitafaa39bdb2aab9490e8e3fdeb1deb754caa3e91b (patch)
treeeb8d1da8d45a447308a40ca4bfbe71a98b421c9a
parent2c17c2eb0fd706a78278bd4e42a02b892eef6dde (diff)
downloadeclipse.platform.swt-afaa39bdb2aab9490e8e3fdeb1deb754caa3e91b.tar.gz
eclipse.platform.swt-afaa39bdb2aab9490e8e3fdeb1deb754caa3e91b.tar.xz
eclipse.platform.swt-afaa39bdb2aab9490e8e3fdeb1deb754caa3e91b.zip
Bug 378081 - Combo should not send ModifyEvent on #select(int) if item unchanged
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java13
2 files changed, 5 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
index a7789bae86..fb63667959 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
@@ -1255,6 +1255,7 @@ public void select (int index) {
int count = getItemCount ();
ignoreSelection = true;
if (0 <= index && index < count) {
+ if (index == getSelectionIndex()) return;
if ((style & SWT.READ_ONLY) != 0) {
((NSPopUpButton)view).selectItemAtIndex(index);
sendEvent (SWT.Modify);
@@ -1563,9 +1564,8 @@ void setText (String string, boolean notify) {
}
if ((style & SWT.READ_ONLY) != 0) {
int index = indexOf (string);
- if (index != -1 && index != getSelectionIndex ()) {
+ if (index != -1) {
select (index);
- if (notify) sendEvent (SWT.Modify);
}
} else {
char[] buffer = new char [Math.min(string.length (), textLimit)];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index c4b4978bd1..e9ee34b2df 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -1632,10 +1632,11 @@ public void removeVerifyListener (VerifyListener listener) {
public void select (int index) {
checkWidget();
if (index < 0 || index >= items.length) return;
+ int selected = OS.gtk_combo_box_get_active (handle);
OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_combo_box_set_active (handle, index);
OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- if ((style & SWT.READ_ONLY) != 0) {
+ if ((style & SWT.READ_ONLY) != 0 && selected != index) {
/*
* Feature in GTK. Read Only combo boxes do not get a chance to send out a
* Modify event in the gtk_changed callback. The fix is to send a Modify event
@@ -1867,15 +1868,7 @@ public void setText (String string) {
if ((style & SWT.READ_ONLY) != 0) {
int index = indexOf (string);
if (index == -1) return;
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- OS.gtk_combo_box_set_active (handle, index);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- /*
- * Feature in GTK. Read Only combo boxes do not get a chance to send out a
- * Modify event in the gtk_changed callback. The fix is to send a Modify event
- * here.
- */
- sendEvent (SWT.Modify);
+ select (index);
return;
}
/*