Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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