Make opening wxComboCtrl popup under MSW work again
This was recently broken in 3bcbc8fe8e (Implement dismissal for
unfocused wxPopupTransientWindow, 2020-07-09) as the changes in it
resulted in the popup being dismissed as soon as it was opened with a
mouse click.
Fix this by changing several things:
- Check for wxCurrentPopupWindow before processing the message, not
after, as the message handler itself could create a new popup and we
definitely don't want to dismiss it immediately after its creation.
- Check for mouse DOWN events only, not UP and DBLCLK ones, as otherwise
it might be possible that UP matching the same DOWN whose handler
showed the popup would dismiss it. As for DBLCLK, it's just
unnecessary, as it should be always preceded by a DOWN message anyhow.
- Don't dismiss the popup if the message is sent to it or one of its
children, as in this case the popup itself is supposed to deal with it
(as wxComboCtrl popup does) and we don't want to prevent it from doing
it.
With these changes both wxComboCtrl and wxTipWindow seem to work as
expected.
Closes #18844.
This commit is contained in:
@@ -2952,6 +2952,33 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
||||
// for most messages we should return 0 when we do process the message
|
||||
rc.result = 0;
|
||||
|
||||
// Special hook for dismissing the current popup if it's active. It's a bit
|
||||
// ugly to have to do this here, but the only alternatives seem to be
|
||||
// installing a WH_CBT hook in wxPopupTransientWindow code, which is not
|
||||
// really much better.
|
||||
#if wxUSE_POPUPWIN
|
||||
// Note that we let the popup window, or its child, have the event if it
|
||||
// happens inside it -- it's supposed to react to it and we don't want to
|
||||
// dismiss it before it can do it.
|
||||
if ( wxCurrentPopupWindow && !wxCurrentPopupWindow->IsDescendant(this) )
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case WM_NCLBUTTONDOWN:
|
||||
case WM_NCRBUTTONDOWN:
|
||||
case WM_NCMBUTTONDOWN:
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_MBUTTONDOWN:
|
||||
|
||||
case WM_SETFOCUS:
|
||||
case WM_KILLFOCUS:
|
||||
wxCurrentPopupWindow->MSWDismissUnfocusedPopup();
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_POPUPWIN
|
||||
|
||||
switch ( message )
|
||||
{
|
||||
case WM_CREATE:
|
||||
@@ -3844,42 +3871,6 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
||||
}
|
||||
}
|
||||
|
||||
// Special hook for dismissing the current popup if it's active. It's a bit
|
||||
// ugly to have to do this here, but the only alternatives seem to be
|
||||
// installing a WH_CBT hook in wxPopupTransientWindow code, which is not
|
||||
// really much better.
|
||||
#if wxUSE_POPUPWIN
|
||||
if ( wxCurrentPopupWindow )
|
||||
{
|
||||
switch ( message )
|
||||
{
|
||||
case WM_NCLBUTTONDOWN:
|
||||
case WM_NCLBUTTONUP:
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
case WM_NCRBUTTONDOWN:
|
||||
case WM_NCRBUTTONUP:
|
||||
case WM_NCRBUTTONDBLCLK:
|
||||
case WM_NCMBUTTONDOWN:
|
||||
case WM_NCMBUTTONUP:
|
||||
case WM_NCMBUTTONDBLCLK:
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
|
||||
case WM_SETFOCUS:
|
||||
case WM_KILLFOCUS:
|
||||
wxCurrentPopupWindow->MSWDismissUnfocusedPopup();
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_POPUPWIN
|
||||
|
||||
if ( !processed )
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user