Allow using ESC as accelerator in wxMSW again.
This ended up being broken due to an interplay between different unrelated changes (at least r15120 and r41134) which were both correct, but didn't work well together and resulted in not only preventing IsDialogMessage() from handling ESC, but also our own accelerator tables. Fix this by doing the check for IsDialogMessage() brokenness in MSWProcessMessage() itself, just before calling it, instead of doing it in MSWShouldPreProcessMessage() which is (and must be) called before MSWTranslateMessage() which checks for accelerators using ESC. Closes #3813. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77071 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -694,6 +694,13 @@ private:
|
|||||||
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
|
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
|
||||||
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||||
|
|
||||||
|
#ifndef __WXUNIVERSAL__
|
||||||
|
// Call ::IsDialogMessage() if it is safe to do it (i.e. if it's not going
|
||||||
|
// to hang or do something else stupid) with the given message, return true
|
||||||
|
// if the message was handled by it.
|
||||||
|
bool MSWSafeIsDialogMessage(WXMSG* msg);
|
||||||
|
#endif // __WXUNIVERSAL__
|
||||||
|
|
||||||
#if wxUSE_DEFERRED_SIZING
|
#if wxUSE_DEFERRED_SIZING
|
||||||
protected:
|
protected:
|
||||||
// this function is called after the window was resized to its new size
|
// this function is called after the window was resized to its new size
|
||||||
|
@@ -2577,7 +2577,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ::IsDialogMessage(GetHwnd(), msg) )
|
if ( MSWSafeIsDialogMessage(msg) )
|
||||||
{
|
{
|
||||||
// IsDialogMessage() did something...
|
// IsDialogMessage() did something...
|
||||||
return true;
|
return true;
|
||||||
@@ -2608,12 +2608,16 @@ bool wxWindowMSW::MSWTranslateMessage(WXMSG* pMsg)
|
|||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
|
bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* WXUNUSED(msg))
|
||||||
{
|
{
|
||||||
// all tests below have to deal with various bugs/misfeatures of
|
// We don't have any reason to not preprocess messages at this level.
|
||||||
// IsDialogMessage(): we have to prevent it from being called from our
|
return true;
|
||||||
// MSWProcessMessage() in some situations
|
}
|
||||||
|
|
||||||
|
#ifndef __WXUNIVERSAL__
|
||||||
|
|
||||||
|
bool wxWindowMSW::MSWSafeIsDialogMessage(WXMSG* msg)
|
||||||
|
{
|
||||||
// don't let IsDialogMessage() get VK_ESCAPE as it _always_ eats the
|
// don't let IsDialogMessage() get VK_ESCAPE as it _always_ eats the
|
||||||
// message even when there is no cancel button and when the message is
|
// message even when there is no cancel button and when the message is
|
||||||
// needed by the control itself: in particular, it prevents the tree in
|
// needed by the control itself: in particular, it prevents the tree in
|
||||||
@@ -2627,12 +2631,8 @@ bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
|
|||||||
// going into an infinite loop when it tries to find the control to give
|
// going into an infinite loop when it tries to find the control to give
|
||||||
// focus to when Alt-<key> is pressed, so we try to detect [some of] the
|
// focus to when Alt-<key> is pressed, so we try to detect [some of] the
|
||||||
// situations when this may happen and not call it then
|
// situations when this may happen and not call it then
|
||||||
if ( msg->message != WM_SYSCHAR )
|
if ( msg->message == WM_SYSCHAR )
|
||||||
return true;
|
{
|
||||||
|
|
||||||
// assume we can call it by default
|
|
||||||
bool canSafelyCallIsDlgMsg = true;
|
|
||||||
|
|
||||||
HWND hwndFocus = ::GetFocus();
|
HWND hwndFocus = ::GetFocus();
|
||||||
|
|
||||||
// if the currently focused window itself has WS_EX_CONTROLPARENT style,
|
// if the currently focused window itself has WS_EX_CONTROLPARENT style,
|
||||||
@@ -2649,7 +2649,7 @@ bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
|
|||||||
if ( ::GetWindowLong(hwndFocus, GWL_EXSTYLE) & WS_EX_CONTROLPARENT )
|
if ( ::GetWindowLong(hwndFocus, GWL_EXSTYLE) & WS_EX_CONTROLPARENT )
|
||||||
{
|
{
|
||||||
// pessimistic by default
|
// pessimistic by default
|
||||||
canSafelyCallIsDlgMsg = false;
|
bool canSafelyCallIsDlgMsg = false;
|
||||||
for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
|
for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
|
||||||
node;
|
node;
|
||||||
node = node->GetNext() )
|
node = node->GetNext() )
|
||||||
@@ -2664,11 +2664,12 @@ bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !canSafelyCallIsDlgMsg )
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif // !__WXWINCE__
|
#endif // !__WXWINCE__
|
||||||
|
|
||||||
if ( canSafelyCallIsDlgMsg )
|
|
||||||
{
|
|
||||||
// ::IsDialogMessage() can enter in an infinite loop when the
|
// ::IsDialogMessage() can enter in an infinite loop when the
|
||||||
// currently focused window is disabled or hidden and its
|
// currently focused window is disabled or hidden and its
|
||||||
// parent has WS_EX_CONTROLPARENT style, so don't call it in
|
// parent has WS_EX_CONTROLPARENT style, so don't call it in
|
||||||
@@ -2679,9 +2680,7 @@ bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
|
|||||||
!::IsWindowVisible(hwndFocus) )
|
!::IsWindowVisible(hwndFocus) )
|
||||||
{
|
{
|
||||||
// it would enter an infinite loop if we do this!
|
// it would enter an infinite loop if we do this!
|
||||||
canSafelyCallIsDlgMsg = false;
|
return false;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !(::GetWindowLong(hwndFocus, GWL_STYLE) & WS_CHILD) )
|
if ( !(::GetWindowLong(hwndFocus, GWL_STYLE) & WS_CHILD) )
|
||||||
@@ -2696,9 +2695,11 @@ bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return canSafelyCallIsDlgMsg;
|
return ::IsDialogMessage(GetHwnd(), msg) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // __WXUNIVERSAL__
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// message params unpackers
|
// message params unpackers
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user