Bug 23103: [DCR]TableColumn doesnt support popup menus
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 5f76350..d0479cb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -2018,6 +2018,7 @@
OS.class_addMethod(cls, OS.sel_mouseDown_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
OS.class_addMethod(cls, OS.sel_updateTrackingAreas, proc2, "@:");
+ OS.class_addMethod(cls, OS.sel_menuForEvent_, proc3, "@:@");
//TODO hitTestProc and drawRectProc should be set Control.setRegion()?
OS.objc_registerClassPair(cls);
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 eb2f5e4..f7f5349 100755
--- 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
@@ -1027,6 +1027,18 @@
return (int)checkColumn.dataCell().cellSize().width;
}
+public Rectangle getClientArea () {
+ checkWidget ();
+ Rectangle rect = super.getClientArea ();
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ rect.y -= height;
+ rect.height += height;
+ }
+ return rect;
+}
+
TableColumn getColumn (id id) {
for (int i = 0; i < columnCount; i++) {
if (columns[i].nsColumn.id == id.id) {
@@ -1619,29 +1631,30 @@
return view.id == headerView.id;
}
-/*
- * Feature in Cocoa: Table views do not change the selection when the user
- * right-clicks or control-clicks on an NSTableView or its subclasses. Fix is to select the
- * clicked-on row ourselves.
- */
int /*long*/ menuForEvent(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
- NSEvent event = new NSEvent(theEvent);
- NSTableView table = (NSTableView)view;
-
- // get the current selections for the table view.
- NSIndexSet selectedRowIndexes = table.selectedRowIndexes();
-
- // select the row that was clicked before showing the menu for the event
- NSPoint mousePoint = view.convertPoint_fromView_(event.locationInWindow(), null);
- int /*long*/ row = table.rowAtPoint(mousePoint);
-
- // figure out if the row that was just clicked on is currently selected
- if (selectedRowIndexes.containsIndex(row) == false) {
- NSIndexSet indexes = new NSIndexSet (NSIndexSet.indexSetWithIndex (row));
- table.selectRowIndexes (indexes, false);
+ if (id != headerView.id) {
+ /*
+ * Feature in Cocoa: Table views do not change the selection when the user
+ * right-clicks or control-clicks on an NSTableView or its subclasses. Fix is to select the
+ * clicked-on row ourselves.
+ */
+ NSEvent event = new NSEvent(theEvent);
+ NSTableView table = (NSTableView)view;
+
+ // get the current selections for the table view.
+ NSIndexSet selectedRowIndexes = table.selectedRowIndexes();
+
+ // select the row that was clicked before showing the menu for the event
+ NSPoint mousePoint = view.convertPoint_fromView_(event.locationInWindow(), null);
+ int /*long*/ row = table.rowAtPoint(mousePoint);
+
+ // figure out if the row that was just clicked on is currently selected
+ if (selectedRowIndexes.containsIndex(row) == false) {
+ NSIndexSet indexes = new NSIndexSet (NSIndexSet.indexSetWithIndex (row));
+ table.selectRowIndexes (indexes, false);
+ }
+ // else that row is currently selected, so don't change anything.
}
- // else that row is currently selected, so don't change anything.
-
return super.menuForEvent(id, sel, theEvent);
}
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 20556c3..1e53c29 100755
--- 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
@@ -1014,6 +1014,18 @@
return (int)checkColumn.dataCell().cellSize().width;
}
+public Rectangle getClientArea () {
+ checkWidget ();
+ Rectangle rect = super.getClientArea ();
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ rect.y -= height;
+ rect.height += height;
+ }
+ return rect;
+}
+
TreeColumn getColumn (id id) {
for (int i = 0; i < columnCount; i++) {
if (columns[i].nsColumn.id == id.id) {
@@ -1580,28 +1592,30 @@
return view.id == headerView.id;
}
-/*
- * Feature in Cocoa: Table views do not change the selection when the user
- * right-clicks or control-clicks on an NSTableView or its subclasses. Fix is to select the
- * clicked-on row ourselves.
- */
int /*long*/ menuForEvent(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
- NSEvent event = new NSEvent(theEvent);
- NSOutlineView tree = (NSOutlineView)view;
-
- // get the current selections for the outline view.
- NSIndexSet selectedRowIndexes = tree.selectedRowIndexes();
-
- // select the row that was clicked before showing the menu for the event
- NSPoint mousePoint = view.convertPoint_fromView_(event.locationInWindow(), null);
- int /*long*/ row = tree.rowAtPoint(mousePoint);
-
- // figure out if the row that was just clicked on is currently selected
- if (selectedRowIndexes.containsIndex(row) == false) {
- NSIndexSet indexes = new NSIndexSet (NSIndexSet.indexSetWithIndex (row));
- tree.selectRowIndexes (indexes, false);
+ if (id != headerView.id) {
+ /*
+ * Feature in Cocoa: Table views do not change the selection when the user
+ * right-clicks or control-clicks on an NSTableView or its subclasses. Fix is to select the
+ * clicked-on row ourselves.
+ */
+ NSEvent event = new NSEvent(theEvent);
+ NSOutlineView tree = (NSOutlineView)view;
+
+ // get the current selections for the outline view.
+ NSIndexSet selectedRowIndexes = tree.selectedRowIndexes();
+
+ // select the row that was clicked before showing the menu for the event
+ NSPoint mousePoint = view.convertPoint_fromView_(event.locationInWindow(), null);
+ int /*long*/ row = tree.rowAtPoint(mousePoint);
+
+ // figure out if the row that was just clicked on is currently selected
+ if (selectedRowIndexes.containsIndex(row) == false) {
+ NSIndexSet indexes = new NSIndexSet (NSIndexSet.indexSetWithIndex (row));
+ tree.selectRowIndexes (indexes, false);
+ }
+ // else that row is currently selected, so don't change anything.
}
- // else that row is currently selected, so don't change anything.
return super.menuForEvent(id, sel, theEvent);
}