Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2013-08-27 16:21:03 -0400
committerBogdan Gheorghe2013-08-27 16:21:03 -0400
commitd204b3013dcf72fc17580360d03d7bef4b0c10e5 (patch)
tree32ef3e5dd3eb51abbe826986d307d8f98ffeabb3
parentf6e9442cd090786347c6c86e66bdbc958146002f (diff)
downloadeclipse.platform.swt-d204b3013dcf72fc17580360d03d7bef4b0c10e5.tar.gz
eclipse.platform.swt-d204b3013dcf72fc17580360d03d7bef4b0c10e5.tar.xz
eclipse.platform.swt-d204b3013dcf72fc17580360d03d7bef4b0c10e5.zip
Bug 409029 - CTabFolder context menu opens in the wrong place when invoked by the keyboard
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
index 1b878bdab5..8fc0086ec6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -274,6 +274,7 @@ void init(int style) {
case SWT.FocusIn: onFocus(event); break;
case SWT.FocusOut: onFocus(event); break;
case SWT.KeyDown: onKeyDown(event); break;
+ case SWT.MenuDetect: onMenuDetect(event); break;
case SWT.MouseDoubleClick: onMouseDoubleClick(event); break;
case SWT.MouseDown: onMouse(event); break;
case SWT.MouseEnter: onMouse(event); break;
@@ -295,6 +296,7 @@ void init(int style) {
SWT.FocusIn,
SWT.FocusOut,
SWT.KeyDown,
+ SWT.MenuDetect,
SWT.MouseDoubleClick,
SWT.MouseDown,
SWT.MouseEnter,
@@ -1647,6 +1649,23 @@ boolean onMnemonic (Event event, boolean doit) {
}
return false;
}
+void onMenuDetect(Event event) {
+ if (event.detail == SWT.MENU_KEYBOARD) {
+ if (selectedIndex != -1) {
+ CTabItem item = items[selectedIndex];
+ Rectangle rect = getDisplay().map(this, null, item.getBounds());
+ if (!rect.contains(event.x, event.y)) {
+ /* If the mouse is not in the currently-selected tab,
+ * then pop up the menu near the top-right corner of the current tab.
+ */
+ Rectangle itemTrim = renderer.computeTrim(selectedIndex, SWT.NONE, 0, 0, 0, 0);
+ Rectangle closeTrim = renderer.computeTrim(CTabFolderRenderer.PART_CLOSE_BUTTON, SWT.NONE, 0, 0, 0, 0);
+ event.x = rect.x + rect.width - item.closeRect.width + itemTrim.x - closeTrim.width;
+ event.y = rect.y - itemTrim.y - closeTrim.y;
+ }
+ }
+ }
+}
void onMouseDoubleClick(Event event) {
if (event.button != 1 ||
(event.stateMask & SWT.BUTTON2) != 0 ||

Back to the top