Implementing Photoshop-like focus policy

Bill Baxter wbaxter at gmail.com
Sat Jun 30 17:33:44 PDT 2007


I'm still trying to figure out how to do App level key handling.  I thought
it was working at first.  But there are some issues.

The main issue I have right now is that the App key handler gets called
*twice* with every key event.  For instance if you just stick add a key down
hander in the auidemo's MyApp and try hitting a key, you get two calls to
MyApp::OnKeyDown with the same event.

Here are the stack traces for the two (wxMSW 2.8.4):
----------------------------------------------------------------
auidemo.exe!MyApp::OnKeyDown(wxKeyEvent & event=3D{...})  Line 49 C++
auidemo.exe!wxAppConsole::HandleEvent(wxEvtHandler * handler=3D0x00c67918,
void (wxEvent &)* func=3D0x00415e60, wxEvent & event=3D{...})  Line 320 + 0=
xc
C++
auidemo.exe!wxEvtHandler::ProcessEventIfMatches(const wxEventTableEntryBase
& entry=3D{...}, wxEvtHandler * handler=3D0x00c67918, wxEvent &
event=3D{...})  Line 1204 + 0x24 C++
auidemo.exe!wxEventHashTable::HandleEvent(wxEvent & event=3D{...},
wxEvtHandler * self=3D0x00c67918)  Line 878 + 0x1c C++
auidemo.exe!wxEvtHandler::ProcessEvent(wxEvent & event=3D{...})  Line 1266 +
0x23 C++
auidemo.exe!wxEvtHandler::TryParent(wxEvent & event=3D{...})  Line 1229 + 0=
x19
C++
auidemo.exe!wxWindowBase::TryParent(wxEvent & event=3D{...})  Line 2601 C++
auidemo.exe!wxEvtHandler::ProcessEvent(wxEvent & event=3D{...})  Line 1279 +
0x11 C++
auidemo.exe!wxEvtHandler::ProcessEvent(wxEvent & event=3D{...})  Line 1273 +
0x1c C++
auidemo.exe!wxScrollHelperEvtHandler::ProcessEvent(wxEvent &
event=3D{...})  Line 211 + 0xc C++
auidemo.exe!wxWindow::HandleKeyDown(unsigned int wParam=3D82, long
lParam=3D1245185)  Line 5232 + 0x1c C++
auidemo.exe!wxWindow::MSWWindowProc(unsigned int message=3D256, unsigned int
wParam=3D82, long lParam=3D1245185)  Line 2901 + 0x11 C++
auidemo.exe!wxScrolledWindow::MSWWindowProc(unsigned int nMsg=3D256, unsign=
ed
int wParam=3D82, long lParam=3D1245185)  Line 1386 + 0x14 C++
auidemo.exe!wxWndProc(HWND__ * hWnd=3D0x000210ac, unsigned int message=3D25=
6,
unsigned int wParam=3D82, long lParam=3D1245185)  Line 2528 + 0x1c C++


---------------------------------------------------------------------------=
---------------
And here is the second:

auidemo.exe!MyApp::OnKeyDown(wxKeyEvent & event=3D{...})  Line 49 C++
auidemo.exe!wxAppConsole::HandleEvent(wxEvtHandler * handler=3D0x00c67918,
void (wxEvent &)* func=3D0x00415e60, wxEvent & event=3D{...})  Line 320 + 0=
xc
C++
auidemo.exe!wxEvtHandler::ProcessEventIfMatches(const wxEventTableEntryBase
& entry=3D{...}, wxEvtHandler * handler=3D0x00c67918, wxEvent &
event=3D{...})  Line 1204 + 0x24 C++
auidemo.exe!wxEventHashTable::HandleEvent(wxEvent & event=3D{...},
wxEvtHandler * self=3D0x00c67918)  Line 878 + 0x1c C++
auidemo.exe!wxEvtHandler::ProcessEvent(wxEvent & event=3D{...})  Line 1266 +
0x23 C++
auidemo.exe!wxEvtHandler::TryParent(wxEvent & event=3D{...})  Line 1229 + 0=
x19
C++
auidemo.exe!wxEvtHandler::ProcessEvent(wxEvent & event=3D{...})  Line 1279 +
0x11 C++
auidemo.exe!wxScrollHelperEvtHandler::ProcessEvent(wxEvent &
event=3D{...})  Line 211 + 0xc C++
auidemo.exe!wxWindow::HandleKeyDown(unsigned int wParam=3D82, long
lParam=3D1245185)  Line 5232 + 0x1c C++
auidemo.exe!wxWindow::MSWWindowProc(unsigned int message=3D256, unsigned int
wParam=3D82, long lParam=3D1245185)  Line 2901 + 0x11 C++
auidemo.exe!wxScrolledWindow::MSWWindowProc(unsigned int nMsg=3D256, unsign=
ed
int wParam=3D82, long lParam=3D1245185)  Line 1386 + 0x14 C++
auidemo.exe!wxWndProc(HWND__ * hWnd=3D0x000210ac, unsigned int message=3D25=
6,
unsigned int wParam=3D82, long lParam=3D1245185)  Line 2528 + 0x1c C++


--------
Is there some way to arrange it so that the App's handler only gets called
once?  Or is there some way to distinguish the two calls (the two
wxKeyEvents looked identical to me, but maybe I missed something)?  Or can I
count on their always being exactly two calls and use a counter variable in
the App to decide which events to ignore?

Thanks for any info,
--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070701/60d=
59a13/attachment.htm


More information about the wx-users mailing list