Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java44
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java43
2 files changed, 62 insertions, 25 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 bee0d9b369..8b9832b9c9 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
@@ -74,8 +74,8 @@ public class Table extends Composite {
NSTableColumn firstColumn, checkColumn;
NSTextFieldCell dataCell;
NSButtonCell buttonCell;
- int columnCount, itemCount, lastIndexOf, sortDirection;
- boolean ignoreSelect, fixScrollWidth, drawExpansion, didSelect, preventSelect;
+ int columnCount, itemCount, lastIndexOf, sortDirection, selectedRowIndex = -1;
+ boolean ignoreSelect, fixScrollWidth, drawExpansion, didSelect, preventSelect, dragDetected;
Rectangle imageBounds;
/* Used to control drop feedback when FEEDBACK_SCROLL is set/not set */
@@ -1990,17 +1990,7 @@ void mouseDownSuper(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
if (!check && row != -1 && (nsEvent.modifierFlags() & OS.NSDeviceIndependentModifierFlagsMask) == 0 && nsEvent.clickCount() == 1) {
if (widget.isRowSelected(row)) {
if (0 <= row && row < itemCount) {
- Event event = new Event ();
- event.item = _getItem ((int)/*64*/row);
- sendSelectionEvent (SWT.Selection, event, false);
-
- // Feature in Cocoa: This code path handles the case of an unmodified click on an already-selected row.
- // If other rows are selected they will de-select and fire a tableViewSelectionDidChange message.
- // To keep the order of events correct, send the selection event here and ignore the next
- // tableViewSelectionDidChange message. We'll reset the flag when the message is received.
- if (widget.selectedRowIndexes().count() > 1) {
- ignoreSelect = true;
- }
+ selectedRowIndex = row;
}
}
}
@@ -3340,6 +3330,34 @@ boolean tableView_writeRowsWithIndexes_toPasteboard(int /*long*/ id, int /*long*
return sendMouseEvent(NSApplication.sharedApplication().currentEvent(), SWT.DragDetect, true);
}
+boolean sendMouseEvent(NSEvent nsEvent, int type, boolean send) {
+ if (type == SWT.DragDetect) {
+ dragDetected = true;
+ } else if (type == SWT.MouseUp) {
+ if (!dragDetected && selectedRowIndex != -1) {
+ NSTableView widget = (NSTableView)view;
+ NSIndexSet selectedRows = widget.selectedRowIndexes ();
+ int count = (int)/*64*/selectedRows.count();
+ int /*long*/ [] indexBuffer = new int /*long*/ [count];
+ selectedRows.getIndexes(indexBuffer, count, 0);
+ for (int i = 0; i < count; i++) {
+ if (indexBuffer[i] == selectedRowIndex) continue;
+ ignoreSelect = true;
+ widget.deselectRow (indexBuffer[i]);
+ ignoreSelect = false;
+ }
+
+ Event event = new Event ();
+ event.item = _getItem ((int)/*64*/selectedRowIndex);
+ selectedRowIndex = -1;
+ sendSelectionEvent (SWT.Selection, event, false);
+ }
+ dragDetected = false;
+ }
+
+ return super.sendMouseEvent (nsEvent, type, send);
+}
+
NSRect titleRectForBounds (int /*long*/ id, int /*long*/ sel, NSRect cellFrame) {
NSImage image = new NSCell(id).image();
if (image != null) {
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 f71d48025d..ccfa08c883 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
@@ -83,7 +83,8 @@ public class Tree extends Composite {
TreeColumn sortColumn;
int columnCount;
int sortDirection;
- boolean ignoreExpand, ignoreSelect, ignoreRedraw, reloadPending, drawExpansion, didSelect, preventSelect;
+ int selectedRowIndex = -1;
+ boolean ignoreExpand, ignoreSelect, ignoreRedraw, reloadPending, drawExpansion, didSelect, preventSelect, dragDetected;
Rectangle imageBounds;
TreeItem insertItem;
boolean insertBefore;
@@ -2036,17 +2037,7 @@ void mouseDownSuper(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
if (!OS.NSPointInRect(pt, rect)) {
Widget item = itemID != null ? display.getWidget (itemID.id) : null;
if (item != null && item instanceof TreeItem) {
- Event event = new Event ();
- event.item = item;
- sendSelectionEvent (SWT.Selection, event, false);
-
- // Feature in Cocoa: This code path handles the case of an unmodified click on an already-selected row.
- // If other rows are selected they will de-select and fire a outlineViewSelectionDidChange message.
- // To keep the order of events correct, send the selection event here and ignore the next
- // outlineViewSelectionDidChange message. We'll reset the flag when the message is received.
- if (widget.selectedRowIndexes().count() > 1) {
- ignoreSelect = true;
- }
+ selectedRowIndex = this.indexOf ((TreeItem)item);
}
}
}
@@ -2637,6 +2628,34 @@ void sendMeasureItem (TreeItem item, boolean selected, int columnIndex, NSSize s
}
}
+boolean sendMouseEvent(NSEvent nsEvent, int type, boolean send) {
+ if (type == SWT.DragDetect) {
+ dragDetected = true;
+ } else if (type == SWT.MouseUp) {
+ if (!dragDetected && selectedRowIndex != -1) {
+ NSTableView widget = (NSTableView)view;
+ NSIndexSet selectedRows = widget.selectedRowIndexes ();
+ int count = (int)/*64*/selectedRows.count();
+ int /*long*/ [] indexBuffer = new int /*long*/ [count];
+ selectedRows.getIndexes(indexBuffer, count, 0);
+ for (int i = 0; i < count; i++) {
+ if (indexBuffer[i] == selectedRowIndex) continue;
+ ignoreSelect = true;
+ widget.deselectRow (indexBuffer[i]);
+ ignoreSelect = false;
+ }
+
+ Event event = new Event ();
+ event.item = _getItem (null, selectedRowIndex, true);
+ selectedRowIndex = -1;
+ sendSelectionEvent (SWT.Selection, event, false);
+ }
+ dragDetected = false;
+ }
+
+ return super.sendMouseEvent (nsEvent, type, send);
+}
+
void selectItems (TreeItem[] items, boolean ignoreDisposed) {
NSOutlineView outlineView = (NSOutlineView) view;
NSMutableIndexSet set = (NSMutableIndexSet) new NSMutableIndexSet ().alloc ().init ();

Back to the top