Top-level window focus handling

slava 2006-05-28 22:35:01 +00:00
parent 628c9de692
commit 805d73ca22
3 changed files with 23 additions and 2 deletions

View File

@ -63,7 +63,8 @@ M: word summary ( word -- )
] if ; ] if ;
M: input summary ( input -- ) M: input summary ( input -- )
"Input: " swap input-string unparse-short append ; "Input: " swap input-string
dup string? [ unparse-short ] unless append ;
: format-column ( list ? -- list ) : format-column ( list ? -- list )
>r [ unparse-short ] map r> [ >r [ unparse-short ] map r> [

View File

@ -55,7 +55,7 @@ sequences ;
frame-content-rect frame-content-rect
] ]
} }
{ {
"windowDidMove:" "void" { "id" "SEL" "id" } [ "windowDidMove:" "void" { "id" "SEL" "id" } [
2nip [object] 2nip [object]
@ -63,6 +63,18 @@ sequences ;
swap [contentView] window set-world-loc swap [contentView] window set-world-loc
] ]
} }
{
"windowDidBecomeKey:" "void" { "id" "SEL" "id" } [
2nip [object] [contentView] window focus-world
]
}
{
"windowDidResignKey:" "void" { "id" "SEL" "id" } [
2nip [object] [contentView] window unfocus-world
]
}
} { } define-objc-class } { } define-objc-class
: install-window-delegate ( window -- ) : install-window-delegate ( window -- )

View File

@ -105,6 +105,14 @@ V{ } clone hand-buttons set-global
: request-focus ( gadget -- ) : request-focus ( gadget -- )
dup focusable-child swap find-world request-focus* ; dup focusable-child swap find-world request-focus* ;
: focus-world ( world -- )
#! Sent when native window receives focus
focused-ancestors f focus-gestures ;
: unfocus-world ( world -- )
#! Sent when native window loses focus.
focused-ancestors f swap focus-gestures ;
: modifier ( mod modifiers -- seq ) : modifier ( mod modifiers -- seq )
[ second swap bitand 0 > ] subset-with [ second swap bitand 0 > ] subset-with
[ first ] map f like ; [ first ] map f like ;