Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2016-01-11 06:57:50 -0500
committerLakshmi Shanmugam2016-01-11 06:57:50 -0500
commitb1839f6c6b2baf7c561dcce92a40d747c5aae146 (patch)
tree2449b4894087526966355d943336b8c8922fa9cb
parent3e30fac11a11e522e98cb140095cc4e29c2d4371 (diff)
downloadeclipse.platform.swt-b1839f6c6b2baf7c561dcce92a40d747c5aae146.tar.gz
eclipse.platform.swt-b1839f6c6b2baf7c561dcce92a40d747c5aae146.tar.xz
eclipse.platform.swt-b1839f6c6b2baf7c561dcce92a40d747c5aae146.zip
Bug 481611 - Table/tree column header events have incorrect coordinates
in OS X 10.11 El Capitan In OSX 10.11, the origin of the tree is the header, not the top-left of the rows. Adjust the co-ordinates accordingly. Fixed getClientArea, getTopItem, setTopItem, setTopIndex & getTopIndex() for 10.11. The behavior on older OSX versions remains unchanged.
-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, 72 insertions, 15 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 518e5eedcd..c267cb6f3c 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
@@ -1267,13 +1267,21 @@ int getCheckColumnWidth () {
public Rectangle getClientArea () {
checkWidget ();
Rectangle rect = super.getClientArea ();
- NSTableHeaderView headerView = ((NSTableView) view).headerView ();
- if (headerView != null) {
- // The origin of the table is the top-left of the rows of the table,
- // not the header. Adjust the y value accordingly.
- int height = (int) headerView.bounds ().height;
- rect.y -= height;
- rect.height += height;
+ /*
+ * OSX version < 10.11 - The origin of the table is the top-left of the rows
+ * of the table, not the header. We adjust the y value and height of the rect
+ * accordingly, to include the header.
+ *
+ * OSX 10.11 - The origin of the table is the header and the header's
+ * height is already included in the rect. Hence, we return the rect as is.
+ */
+ if (OS.VERSION_MMB < OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ rect.y -= height;
+ rect.height += height;
+ }
}
return rect;
}
@@ -1773,7 +1781,17 @@ public int getTopIndex () {
NSPoint point = new NSPoint();
point.x = rect.x;
point.y = rect.y;
-
+ /*
+ * In OSX 10.11, the origin of the table is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ point.y += height;
+ }
+ }
int /*64*/ rowAtPoint = (int)/*64*/((NSTableView)view).rowAtPoint(point);
if (rowAtPoint == -1) return 0; /* Empty table */
return rowAtPoint;
@@ -2950,6 +2968,16 @@ public void setTopIndex (int index) {
NSPoint pt = new NSPoint();
pt.x = scrollView.contentView().bounds().x;
pt.y = widget.frameOfCellAtColumn(0, row).y;
+ /*
+ * In OSX 10.11, the origin of the table is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) {
+ if (widget.headerView() != null) {
+ NSRect headerRect = headerView.frame();
+ pt.y -= headerRect.y + headerRect.height;
+ }
+ }
view.scrollPoint(pt);
}
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 bbfd033fc3..d4b34126d5 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
@@ -1339,13 +1339,21 @@ int getCheckColumnWidth () {
public Rectangle getClientArea () {
checkWidget ();
Rectangle rect = super.getClientArea ();
- NSTableHeaderView headerView = ((NSTableView) view).headerView ();
- if (headerView != null) {
- // The origin of the tree is the top-left of the rows of the tree,
- // not the header. Adjust the y value accordingly.
- int height = (int) headerView.bounds ().height;
- rect.y -= height;
- rect.height += height;
+ /*
+ * OSX version < 10.11 - The origin of the tree is the top-left of the rows
+ * of the table, not the header. We adjust the y value and height of the rect
+ * accordingly, to include the header.
+ *
+ * OSX 10.11 & above - The origin of the tree is the header and the header's
+ * height is already included in the rect. Hence, we return the rect as is.
+ */
+ if (OS.VERSION_MMB < OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ rect.y -= height;
+ rect.height += height;
+ }
}
return rect;
}
@@ -1839,6 +1847,17 @@ public TreeItem getTopItem () {
NSPoint point = new NSPoint ();
point.x = rect.x;
point.y = rect.y;
+ /*
+ * In OSX 10.11, the origin of the tree is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ point.y += height;
+ }
+ }
NSOutlineView outlineView = (NSOutlineView)view;
long /*int*/ index = outlineView.rowAtPoint (point);
if (index == -1) return null; /* empty */
@@ -3154,6 +3173,16 @@ public void setTopItem (TreeItem item) {
NSPoint pt = new NSPoint();
pt.x = scrollView.contentView().bounds().x;
pt.y = widget.frameOfCellAtColumn(0, row).y;
+ /*
+ * In OSX 10.11, the origin of the tree is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) {
+ if (widget.headerView() != null) {
+ NSRect headerRect = headerView.frame();
+ pt.y -= headerRect.y + headerRect.height;
+ }
+ }
view.scrollPoint(pt);
}

Back to the top