Button breaks frame focus listener
whamtet opened this issue · 2 comments
whamtet commented
Let's create a frame and attach a listener.
(use 'seesaw.core)
(doto
(frame :content (label "hi"))
(listen :focus-gained (fn [_] (println "hi")))
(-> pack! show!))
The frame prints "hi" as expected. If I change this to a button it no longer works.
(doto
(frame :content (button "hi"))
(listen :focus-gained (fn [_] (println "hi")))
(-> pack! show!))
Presumably the button is stealing the frame's focus listener. Any suggestions?
daveray commented
Do you want to know when the frame has keyboard focus, or just that it's been activated? The form will be problematic for reason's you've already discovered. Keyboard focus is hierarchical and will go to more specific components in the frame. In the latter case, you probably want the :window-activated
event to find out when the user's returned to the frame regardless of which widget ends up with keyboard focus.
Does this help?
whamtet commented
Great! :window-activated
and :window-deactivated
are the events to use!