fix focus problems and implement send-message-to-window in cocoa

This commit is contained in:
Matthew Flatt 2010-09-07 13:52:30 -06:00
parent 955df62409
commit 2a4ea2ef98
6 changed files with 27 additions and 7 deletions

View File

@ -91,6 +91,8 @@ get-font-from-user
get-page-setup-from-user
get-panel-background
get-ps-setup-from-user
get-highlight-background-color
get-highlight-text-color
get-resource
get-text-from-user
get-the-editor-data-class-list

View File

@ -16,12 +16,13 @@
(unsafe!)
(objc-unsafe!)
(provide frame%)
(provide frame%
location->window)
;; ----------------------------------------
(import-class NSWindow NSGraphicsContext NSMenu NSPanel
NSApplication NSAutoreleasePool)
NSApplication NSAutoreleasePool NSScreen)
(define front #f)
@ -30,6 +31,8 @@
(define dialog-level-counter 0)
(define all-windows (make-hash))
(define-objc-mixin (MyWindowMethods Superclass)
[wxb]
[-a _scheme (getEventspace)
@ -242,6 +245,10 @@
[root-fake-frame (send root-fake-frame install-mb)]
[else (void)]))))
(register-frame-shown this on?)
(let ([num (tell #:type _NSInteger cocoa windowNumber)])
(if on?
(hash-set! all-windows num this)
(hash-remove! all-windows num)))
(when on?
(let ([b (eventspace-wait-cursor-count (get-eventspace))])
(set-wait-cursor-mode (not (zero? b))))))))
@ -436,3 +443,13 @@
(define/public (set-title s)
(tellv cocoa setTitle: #:type _NSString s))))
;; ----------------------------------------
(define (location->window x y)
(let ([n (tell #:type _NSInteger NSWindow
windowNumberAtPoint: #:type _NSPoint
(let ([f (tell #:type _NSRect (tell NSScreen mainScreen) frame)])
(make-NSPoint x (- (NSSize-height (NSRect-size f)) y)))
belowWindowWithWindowNumber: #:type _NSInteger 0)])
(atomically (hash-ref all-windows n #f))))

View File

@ -6,6 +6,7 @@
ffi/unsafe/objc
"utils.rkt"
"types.rkt"
"frame.rkt"
"../../lock.rkt"
"../common/handlers.rkt")
@ -25,7 +26,6 @@
shortcut-visible-in-label?
in-atomic-region
set-menu-tester
location->window
set-dialogs
set-executer
send-event
@ -74,7 +74,6 @@
(define-unimplemented in-atomic-region)
(define (set-menu-tester proc)
(void))
(define-unimplemented location->window)
(define (set-dialogs . args)
(void))
(define (set-executer proc)

View File

@ -319,7 +319,10 @@
(with-autorelease
(tellv cocoa removeFromSuperview)))
(set! is-on? (and on? #t))))
(maybe-register-as-child parent on?))
(maybe-register-as-child parent on?)
(unless on?
(focus-is-on #f)
(is-responder this #f)))
(define/public (maybe-register-as-child parent on?)
(void))
(define/public (register-as-child parent on?)

View File

@ -220,4 +220,4 @@
(define/override (on-scroll e)
(editor-canvas-on-scroll))
(super-new)
(set-no-expose-focus))))
#;(set-no-expose-focus))))

View File

@ -13,7 +13,6 @@
(ffi-lib "libpango-1.0.0")]
[(unix) (ffi-lib "libpango-1.0" '("0"))]
[(windows)
; (ffi-lib "msjava")
(ffi-lib "libglib-2.0-0")
(ffi-lib "libgmodule-2.0-0")
(ffi-lib "libgobject-2.0-0")