diff --git a/collects/mred/private/wx/cocoa/menu.rkt b/collects/mred/private/wx/cocoa/menu.rkt index 8d59c1f31a..a7b8bd318e 100644 --- a/collects/mred/private/wx/cocoa/menu.rkt +++ b/collects/mred/private/wx/cocoa/menu.rkt @@ -5,15 +5,17 @@ (only-in scheme/list drop take) "../common/event.rkt" "../../syntax.rkt" + "../../lock.rkt" "utils.rkt" "types.rkt" + "const.rkt" "window.rkt" "menu-item.rkt") (provide (protect-out menu%)) -(import-class NSMenu NSMenuItem) +(import-class NSMenu NSMenuItem NSEvent) (define-struct mitem (item checkable?)) @@ -56,15 +58,36 @@ (define popup-box #f) - (define/public (do-popup v x y queue-cb) + (define/public (do-popup v win x y queue-cb) (unless (null? items) (create-menu "menu") (let ([b (box #f)]) (set! popup-box b) - (tellv cocoa-menu - popUpMenuPositioningItem: (tell cocoa-menu itemAtIndex: #:type _NSUInteger 0) - atLocation: #:type _NSPoint (make-NSPoint x y) - inView: v) + (if #t ;; use the 10.5 code, for now + ;; For 10.5 and earlier: + (let ([p (tell #:type _NSPoint v + convertPoint: #:type _NSPoint (make-NSPoint x y) + toView: #f)]) + (atomically + (with-autorelease + (tellv NSMenu popUpContextMenu: cocoa-menu + withEvent: (tell NSEvent + mouseEventWithType: #:type _int NSLeftMouseDown + location: #:type _NSPoint p + modifierFlags: #:type _NSUInteger 0 + timestamp: #:type _double 0.0 + windowNumber: #:type _NSUInteger + (tell #:type _NSInteger win windowNumber) + context: #:type _pointer #f + eventNumber: #:type _NSInteger 0 + clickCount: #:type _NSInteger 1 + pressure: #:type _float 1.0) + forView: v)))) + ;; 10.6 and later: + (tellv cocoa-menu + popUpMenuPositioningItem: (tell cocoa-menu itemAtIndex: #:type _NSUInteger 0) + atLocation: #:type _NSPoint (make-NSPoint x y) + inView: v)) (set! popup-box #f) (let* ([i (unbox b)] [e (new popup-event% [event-type 'menu-popdown])]) diff --git a/collects/mred/private/wx/cocoa/queue.rkt b/collects/mred/private/wx/cocoa/queue.rkt index 5be58666ae..654b8cca68 100644 --- a/collects/mred/private/wx/cocoa/queue.rkt +++ b/collects/mred/private/wx/cocoa/queue.rkt @@ -103,7 +103,7 @@ (define wake-evt (tell NSEvent otherEventWithType: #:type _int NSApplicationDefined - location: #:type _NSPoint-pointer (make-NSPoint 0.0 0.0) + location: #:type _NSPoint (make-NSPoint 0.0 0.0) modifierFlags: #:type _NSUInteger 0 timestamp: #:type _double 0.0 windowNumber: #:type _NSUInteger 0 diff --git a/collects/mred/private/wx/cocoa/window.rkt b/collects/mred/private/wx/cocoa/window.rkt index 03a199b007..4243556621 100644 --- a/collects/mred/private/wx/cocoa/window.rkt +++ b/collects/mred/private/wx/cocoa/window.rkt @@ -650,7 +650,7 @@ (define/public (get-handle) (get-cocoa)) (define/public (popup-menu m x y) - (send m do-popup (get-cocoa-content) x (flip-client y) + (send m do-popup (get-cocoa-content) (get-cocoa-window) x (flip-client y) (lambda (thunk) (queue-window-event this thunk))))