diff options
author | Carolyn MacLeod <Carolyn_MacLeod@ca.ibm.com> | 2012-04-30 02:20:10 -0400 |
---|---|---|
committer | Carolyn MacLeod <Carolyn_MacLeod@ca.ibm.com> | 2012-04-30 02:20:10 -0400 |
commit | dc8b70b8b17620c5e26d2b27a9531e3a6acaed33 (patch) | |
tree | 192d03c8beef94e4abcca0d65fc8e1b3c131ec5a /bundles | |
parent | e1940a25dd494851997c8f01624f6accfe73fc93 (diff) | |
download | eclipse.platform.swt-dc8b70b8b17620c5e26d2b27a9531e3a6acaed33.tar.gz eclipse.platform.swt-dc8b70b8b17620c5e26d2b27a9531e3a6acaed33.tar.xz eclipse.platform.swt-dc8b70b8b17620c5e26d2b27a9531e3a6acaed33.zip |
Bug 375723 - Handle MENU_KEYBOARD in more widgets
Diffstat (limited to 'bundles')
4 files changed, 63 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java index a6d4a18113..73fe757e29 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java @@ -1508,6 +1508,23 @@ public void showSelection () { OS.SendMessage (handle, OS.LB_SETTOPINDEX, newTop, 0); } +void updateMenuLocation (Event event) { + Rectangle clientArea = getClientArea (); + int x = clientArea.x, y = clientArea.y; + int focusIndex = getFocusIndex(); + if (focusIndex != -1) { + RECT rect = new RECT (); + OS.SendMessage (handle, OS.LB_GETITEMRECT, focusIndex, rect); + x = Math.max (x, rect.right / 2); + x = Math.min (x, clientArea.x + clientArea.width); + y = Math.max (y, rect.bottom); + y = Math.min (y, clientArea.y + clientArea.height); + } + Point pt = toDisplay (x, y); + event.x = pt.x; + event.y = pt.y; +} + int widgetStyle () { int bits = super.widgetStyle () | OS.LBS_NOTIFY | OS.LBS_NOINTEGRALHEIGHT; if ((style & SWT.SINGLE) != 0) return bits; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java index 3c163a1946..55795a857b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java @@ -5609,6 +5609,26 @@ void updateImages () { } } +void updateMenuLocation (Event event) { + Rectangle clientArea = getClientArea (); + int x = clientArea.x, y = clientArea.y; + int focusIndex = getFocusIndex (); + if (focusIndex != -1) { + TableItem focusItem = getItem (focusIndex); + Rectangle bounds = focusItem.getBounds (0); + if (focusItem.text != null && focusItem.text.length () != 0) { + bounds = focusItem.getTextBounds (0); + } + x = Math.max (x, bounds.x + bounds.width / 2); + x = Math.min (x, clientArea.x + clientArea.width); + y = Math.max (y, bounds.y + bounds.height); + y = Math.min (y, clientArea.y + clientArea.height); + } + Point pt = toDisplay (x, y); + event.x = pt.x; + event.y = pt.y; +} + void updateMoveable () { int index = 0; while (index < columnCount) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index 0c6f19ba9b..117acc5dc4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -5535,6 +5535,25 @@ void updateImages () { } } +void updateMenuLocation (Event event) { + Rectangle clientArea = getClientArea (); + int x = clientArea.x, y = clientArea.y; + TreeItem focusItem = getFocusItem (); + if (focusItem != null) { + Rectangle bounds = focusItem.getBounds (0); + if (focusItem.text != null && focusItem.text.length () != 0) { + bounds = focusItem.getTextBounds (0); + } + x = Math.max (x, bounds.x + bounds.width / 2); + x = Math.min (x, clientArea.x + clientArea.width); + y = Math.max (y, bounds.y + bounds.height); + y = Math.min (y, clientArea.y + clientArea.height); + } + Point pt = toDisplay (x, y); + event.x = pt.x; + event.y = pt.y; +} + void updateOrientation () { super.updateOrientation (); RECT rect = new RECT (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index 004079e5a2..67197555ae 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -1466,6 +1466,9 @@ boolean showMenu (int x, int y, int detail) { event.x = x; event.y = y; event.detail = detail; + if (event.detail == SWT.MENU_KEYBOARD) { + updateMenuLocation (event); + } sendEvent (SWT.MenuDetect, event); // widget could be disposed at this point if (isDisposed ()) return false; @@ -1496,6 +1499,10 @@ public String toString () { return getName () + " {" + string + "}"; //$NON-NLS-1$ //$NON-NLS-2$ } +void updateMenuLocation (Event event) { + /* Do nothing */ +} + LRESULT wmCaptureChanged (int /*long*/ hwnd, int /*long*/ wParam, int /*long*/ lParam) { display.captureChanged = true; return null; |