[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

Alex,

FilterEvent is not optimal, it gets called before events are delivered to each window up the chain. This means it may be called 3 times with the same message. What makes this even worse is the fact that it doesn't tell you which window it's going to deliver it to!

Did you ever get an answer about what the event timestamp was? If this is fine grained enough, it may be quite useful to throw-away duplicate events. Having fully implemented the key press handling hanging of FilterEvent, it seems that removing duplicates isn't vital since we mark the events as handled when we actually use them. The only reason I'm interested in dealing with duplicates, is we do some quite expensive operations (IsKindOf and window accestor traversal) to work out whether we can have the keypress.

   Luke