Greets,
What's the best way to implement a photoshop-like focus policy?
What do I mean by that?
* Most key events get handled at the top level (E.g. a plain 'V' key
switches to the move tool pretty much no matter what you are doing at
the given moment.)
* But sometimes something has full focus and consumes key events (like
when you're editing text on the canvas, 'V' inserts a V character).
Initially I tried just forcing focus to the canvas all the time, but
that messes up transient popups and also interferes with having some
items be focusable (like a text box where you can type in the zoom
level, say).
wx.EVT_CHAR_HOOK seems like it might be able to help, but on Windows
it doesn't trap plain alpha-numeric keys, just special ones. It seems
to get all key strokes on Linux, though. Googling I found this issue
was reported by Robin previously and the response was "I thought that
only worked on Windows -- I think it should be private" and there the
conversation ended.
(http://lists.wxwidgets.org/archive/wx-dev/msg00153.html -- But in
fact it seems to work fine on Linux at least.)
So EVT_CHAR_HOOK won't do it. At least not in wx 2.8.4.
So what's a reasonable way to make all key events find their way to
the main app handler? The only other thing I can think to do is to
subclass every button or widget I use to do special key handling. Or
have the top-level frame bind wx.EVT_KEY_DOWN/UP for every single
widget.
Thanks for any help.
--bb