Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2012-03-08 20:39:17 +0000
committerCarolyn MacLeod2012-03-10 21:42:11 +0000
commit6b083490c307e06e3dbe89efcb32f0c23cd5e466 (patch)
treef3c3255cc8efb495027b333a2b1cd342f68c24a4
parent22c98fa42a51e9ecf55469a432543ede877d4e8d (diff)
downloadeclipse.platform.swt-6b083490c307e06e3dbe89efcb32f0c23cd5e466.tar.gz
eclipse.platform.swt-6b083490c307e06e3dbe89efcb32f0c23cd5e466.tar.xz
eclipse.platform.swt-6b083490c307e06e3dbe89efcb32f0c23cd5e466.zip
Initial bug110005 work (Windows)
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java11
5 files changed, 49 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 75de2c0edb..e1a337e42c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -5628,6 +5628,7 @@ void installListeners() {
case SWT.Dispose: handleDispose(event); break;
case SWT.KeyDown: handleKeyDown(event); break;
case SWT.KeyUp: handleKeyUp(event); break;
+ case SWT.MenuDetect: handleMenuDetect(event); break;
case SWT.MouseDown: handleMouseDown(event); break;
case SWT.MouseUp: handleMouseUp(event); break;
case SWT.MouseMove: handleMouseMove(event); break;
@@ -5640,6 +5641,7 @@ void installListeners() {
addListener(SWT.Dispose, listener);
addListener(SWT.KeyDown, listener);
addListener(SWT.KeyUp, listener);
+ addListener(SWT.MenuDetect, listener);
addListener(SWT.MouseDown, listener);
addListener(SWT.MouseUp, listener);
addListener(SWT.MouseMove, listener);
@@ -5960,6 +5962,20 @@ void handleKeyUp(Event event) {
newOrientation = SWT.NONE;
}
}
+/**
+ * Update the event location for focus-based context menu triggers.
+ *
+ * @param event menu detect event
+ */
+void handleMenuDetect(Event event) {
+ if (event.detail == SWT.CONTEXT_FOCUS) {
+ Point point = getPointAtOffset(caretOffset);
+ Display display = getDisplay();
+ point = display.map(this, null, point);
+ event.x = point.x;
+ event.y = point.y;
+ }
+}
/**
* Updates the caret location and selection if mouse button 1 has been
* pressed.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index 4158e426fc..7d21f7375f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -1025,6 +1025,10 @@ public class SWT {
*/
public static final int TOUCHSTATE_UP = 1 << 2;
+ public static final int CONTEXT_NONE = 1 << 0;
+ public static final int CONTEXT_POINTER = 1 << 1;
+ public static final int CONTEXT_FOCUS = 1 << 2;
+
/**
* A constant indicating that widgets have changed.
* (value is 1&lt;&lt;1).
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java
index 8f36c30d39..6d48d91773 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuDetectEvent.java
@@ -43,6 +43,25 @@ public final class MenuDetectEvent extends TypedEvent {
*/
public boolean doit;
+ /**
+ * The event trigger type.
+ * <p><ul>
+ * <li>{@link org.eclipse.swt.SWT#CONTEXT_NONE}</li>
+ * <li>{@link org.eclipse.swt.SWT#CONTEXT_POINTER}</li>
+ * <li>{@link org.eclipse.swt.SWT#CONTEXT_FOCUS}</li>
+ * </ul></p>
+ *
+ * A field indicating whether the event was triggered by a pointing device,
+ * such as a mouse, or by a focus-based device such as a keyboard.
+ * If the trigger was CONTEXT_FOCUS, then the application should provide
+ * new display-relative x and y coordinates based on the current
+ * selection or the current focus.
+ *
+ * @since 3.8
+ */
+ public int detail;
+
+
private static final long serialVersionUID = -3061660596590828941L;
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java
index ca560377ca..2fcc1f2f24 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java
@@ -185,6 +185,7 @@ public void handleEvent (Event e) {
e.x = event.x;
e.y = event.y;
e.doit = event.doit;
+ e.detail = event.detail;
break;
}
case SWT.MouseDown: {
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 65ceaa5320..fd9fd44c15 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
@@ -1458,9 +1458,14 @@ boolean SetWindowPos (int /*long*/ hWnd, int /*long*/ hWndInsertAfter, int X, in
}
boolean showMenu (int x, int y) {
+ return showMenu (x, y, SWT.CONTEXT_POINTER);
+}
+
+boolean showMenu (int x, int y, int detail) {
Event event = new Event ();
event.x = x;
event.y = y;
+ event.detail = detail;
sendEvent (SWT.MenuDetect, event);
// widget could be disposed at this point
if (isDisposed ()) return false;
@@ -1540,12 +1545,13 @@ LRESULT wmContextMenu (int /*long*/ hwnd, int /*long*/ wParam, int /*long*/ lPar
* originated from a mouse event and display the menu when the
* mouse was released in the client area.
*/
- int x = 0, y = 0;
+ int x = 0, y = 0, detail = 0;
if (lParam != -1) {
POINT pt = new POINT ();
OS.POINTSTOPOINT (pt, lParam);
x = pt.x;
y = pt.y;
+ detail = SWT.CONTEXT_POINTER;
OS.ScreenToClient (hwnd, pt);
RECT rect = new RECT ();
OS.GetClientRect (hwnd, rect);
@@ -1554,10 +1560,11 @@ LRESULT wmContextMenu (int /*long*/ hwnd, int /*long*/ wParam, int /*long*/ lPar
int pos = OS.GetMessagePos ();
x = OS.GET_X_LPARAM (pos);
y = OS.GET_Y_LPARAM (pos);
+ detail = SWT.CONTEXT_FOCUS;
}
/* Show the menu */
- return showMenu (x, y) ? LRESULT.ZERO : null;
+ return showMenu (x, y, detail) ? LRESULT.ZERO : null;
}
LRESULT wmIMEChar (int /*long*/ hwnd, int /*long*/ wParam, int /*long*/ lParam) {

Back to the top