Don't generate wxEVT_CHAR_HOOK events while the mouse is captured.
This prevents the parent TLW from interfering with the keyboard handling of the window that captured the mouse which very often needs Escape for itself to cancel the capture. In particular, this fixes the problems with Escape closing the entire dialog containing the controls instead of closing just the combobox drop down or a popup menu in wxMSW. Also modify wxGTK for consistency and update the documentation. Closes #12952. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67191 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -884,17 +884,21 @@ bool
|
||||
SendCharHookAndCharEvents(const wxKeyEvent& event, wxWindow *win)
|
||||
{
|
||||
// wxEVT_CHAR_HOOK must be sent to the top level parent window to allow it
|
||||
// to handle key events in all of its children.
|
||||
wxWindow * const parent = wxGetTopLevelParent(win);
|
||||
if ( parent )
|
||||
// to handle key events in all of its children unless the mouse is captured
|
||||
// in which case we consider that the keyboard should be "captured" too.
|
||||
if ( !g_captureWindow )
|
||||
{
|
||||
// We need to make a copy of the event object because it is
|
||||
// modified while it's handled, notably its WasProcessed() flag
|
||||
// is set after it had been processed once.
|
||||
wxKeyEvent eventCharHook(event);
|
||||
eventCharHook.SetEventType(wxEVT_CHAR_HOOK);
|
||||
if ( parent->HandleWindowEvent(eventCharHook) )
|
||||
return true;
|
||||
wxWindow * const parent = wxGetTopLevelParent(win);
|
||||
if ( parent )
|
||||
{
|
||||
// We need to make a copy of the event object because it is
|
||||
// modified while it's handled, notably its WasProcessed() flag
|
||||
// is set after it had been processed once.
|
||||
wxKeyEvent eventCharHook(event);
|
||||
eventCharHook.SetEventType(wxEVT_CHAR_HOOK);
|
||||
if ( parent->HandleWindowEvent(eventCharHook) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// As above, make a copy of the event first.
|
||||
|
Reference in New Issue
Block a user