changeset 702:e9a3d1da3d3e

dw_menu_popup() now uses the coordinates specified instead of the event coorindates.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 11 Mar 2011 05:56:17 +0000
parents c91a1b345f2e
children 329736825f9b
files mac/dw.m
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Fri Mar 11 05:23:17 2011 +0000
+++ b/mac/dw.m	Fri Mar 11 05:56:17 2011 +0000
@@ -4957,10 +4957,20 @@
  */
 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
 {
-	NSMenu *thismenu = (NSMenu *)*menu;
-	NSView *view = parent;
+    NSMenu *thismenu = (NSMenu *)*menu;
+    NSView *view = parent;
+    NSWindow *window = [view window];
     NSEvent *event = [DWApp currentEvent];
-    [NSMenu popUpContextMenu:thismenu withEvent:event forView:view];
+    NSEvent* fake = [NSEvent mouseEventWithType:NSRightMouseDown 
+                                       location:[window convertScreenToBase:NSMakePoint(x, y)]
+                                  modifierFlags:0 
+                                      timestamp:[event timestamp]
+                                   windowNumber:[window windowNumber]
+                                        context:[NSGraphicsContext currentContext] 
+                                    eventNumber:1 
+                                     clickCount:1 
+                                       pressure:0.0];     
+    [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view];
 }
 
 char _removetilde(char *dest, char *src)