[plt-scheme] focus question
Hi all,
I have an editor-snip% subclass with two component editor-snip%s (top-
snip and bottom-snip). I've written a subclass of aligned-pasteboard
% to align these two parts vertically, and so far, that works. I'm
now trying to get this behavior:
1) Initially, the top-snip is hidden.
2) When the pasteboard gets focus (which, to me, means the user
clicks on it to enter text, same as DrS's comment boxes), the top-
snip appears and gets focus. (At this point, the user can also click
the bottom-snip and type into it.)
3) When the pasteboard loses focus, the top-snip is again hidden.
The questions:
- Can I accomplish this with an on-focus handler in the pasteboard?
- Is additional machinery needed, and if so, where?
Here is relevant code from an attempt at the aligned-pasteboard%
subclass:
(inherit get-focus-snip set-caret-owner)
(define/override (on-focus focus?)
(if focus?
(begin
(send the-top-part show #t)
;; the-top-part, above, is a vertical-alignment% I'm using
;; just for the ability to show/hide, as a wrapper
around the snip.
(unless (get-focus-snip)
(set-caret-owner the-top-snip)))
(send top-part show #f)))
I've tested this in the REPL and in an independent window, and it
seems to successfully accomplish (1) and (2), but not (3). My hunch
is that it's because some of the events I want are being handled only
by the component snips, but after reading the docs I'm still not
clear on how to work around that (if indeed that's the case).
Thanks again,
jmj