[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Keypress handling



Alex Bligh wrote:



--On 08 May 2006 11:05 +0100 Luke Hart <lukeh@xxxxxxxx> wrote:

I was never suggesting that we need handlers in multiple windows (with
the inherent problems with selecting the best one). If you read the 2nd
point, I am saying that if we try and handle the events in an ancestor of
the window with focus, the key down event is not received. This what was
causing all the problems Charles reported over the week-end.


Why do it in a window at all? Why not do it in the application (as I
thought you were suggesting) using wxApp::FilterEvent? Then you are
not reliant on trying to catch the focus as it moves around, and on
controls being "nice" with passing through unused key events. You
can get the events before they get to ANY window, see who has focus,
let the event through if you want to (text control etc.), but otherwise
if it is a "page" type operation, process it there and then. You'll
also clearly have to let it through if there is a modal dialog around,
or a menu is up, but this unifies the entire handling to a single
place - the application - which is guaranteed to get the events before
the focus window, as I understand it, because FilterEvent works BEFORE
the normal event handling chain and is application-global.

Alex

Centralised key handling sounds like a potential rat's nest to me, since it will have to know information about individual controls, views, documents, windows, application state and focus location. URGH!

Can we not do this in what seems to me the obvious way? I.e. distributed and object-oriented - allow the object at the sharp-end, the one with the focus, to handle its own keypresses and if not, pass them up a command chain?

(Er, note that, that's what the Input Focus handling rules say should happen conceptually so why not /do/ it instead of /simulating/ it...)

Phil