Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2012-10-25 10:20:25 +0000
committerLakshmi Shanmugam2012-10-25 10:27:32 +0000
commit81fc4fbb51e1206ed8a526050d3bdcad1a2f0496 (patch)
tree8e24e7ff186655643bf61ae2bb363254acb18e04
parent48d81c66e4c3a4579b6edbedb9a57af347363ecf (diff)
downloadeclipse.platform.swt-81fc4fbb51e1206ed8a526050d3bdcad1a2f0496.tar.gz
eclipse.platform.swt-81fc4fbb51e1206ed8a526050d3bdcad1a2f0496.tar.xz
eclipse.platform.swt-81fc4fbb51e1206ed8a526050d3bdcad1a2f0496.zip
Prevent extra selection event: Bug 355200-Table and Tree
selection wrong during widgetSelected
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java6
2 files changed, 12 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
index d1116797c5..2caac11780 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
@@ -3334,6 +3334,11 @@ boolean sendMouseEvent(NSEvent nsEvent, int type, boolean send) {
if (type == SWT.DragDetect) {
dragDetected = true;
} else if (type == SWT.MouseUp) {
+ /*
+ * This code path handles the case of an unmodified click on an already-selected row.
+ * To keep the order of events correct, deselect the other selected items and send the
+ * selection event before MouseUp is sent. Ignore the next selection event.
+ */
if (!dragDetected && selectedRowIndex != -1) {
NSTableView widget = (NSTableView)view;
NSIndexSet selectedRows = widget.selectedRowIndexes ();
@@ -3351,6 +3356,7 @@ boolean sendMouseEvent(NSEvent nsEvent, int type, boolean send) {
event.item = _getItem ((int)/*64*/selectedRowIndex);
selectedRowIndex = -1;
sendSelectionEvent (SWT.Selection, event, false);
+ ignoreSelect = true;
}
dragDetected = false;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
index 591e3caeb1..a25d32e0e5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
@@ -2626,6 +2626,11 @@ boolean sendMouseEvent(NSEvent nsEvent, int type, boolean send) {
if (type == SWT.DragDetect) {
dragDetected = true;
} else if (type == SWT.MouseUp) {
+ /*
+ * This code path handles the case of an unmodified click on an already-selected row.
+ * To keep the order of events correct, deselect the other selected items and send the
+ * selection event before MouseUp is sent. Ignore the next selection event.
+ */
if (!dragDetected && selectedRowIndex != -1) {
NSTableView widget = (NSTableView)view;
NSIndexSet selectedRows = widget.selectedRowIndexes ();
@@ -2643,6 +2648,7 @@ boolean sendMouseEvent(NSEvent nsEvent, int type, boolean send) {
event.item = _getItem (null, selectedRowIndex, true);
selectedRowIndex = -1;
sendSelectionEvent (SWT.Selection, event, false);
+ ignoreSelect = true;
}
dragDetected = false;
}

Back to the top