Fix cursor flicker after popup menu in rich wxTextCtrl

After bd650ec and cad2b9c, showing a popup menu in wxTextCtrl with
wxTE_RICH2 and then dismissing it without choosing a command would
result in the cursor flickering between arrow and beam cursors until
another context menu was shown.

See https://github.com/vslavik/poedit/issues/483

Fixed by checking if the popup menu is still valid (and so shown) in
the cursor handling code.
This commit is contained in:
Václav Slavík
2018-05-28 15:41:32 +02:00
committed by Václav Slavík
parent 74904281e4
commit dcac98d7e8

View File

@@ -2262,9 +2262,14 @@ wxTextCtrl::MSWHandleMessage(WXLRESULT *rc,
// for plain EDIT controls though), so explicitly work around this
if ( IsRich() )
{
// wxCurrentPopupMenu stores the popup menu that will receive
// WM_COMMAND, but it may be non-NULL even when the underlying
// native menu is no longer shown. Use ::IsMenu() to check whether
// the menu still exists.
extern wxMenu *wxCurrentPopupMenu;
if ( wxCurrentPopupMenu &&
wxCurrentPopupMenu->GetInvokingWindow() == this )
wxCurrentPopupMenu->GetInvokingWindow() == this &&
::IsMenu(GetHmenuOf(wxCurrentPopupMenu)) )
::SetCursor(GetHcursorOf(*wxSTANDARD_CURSOR));
}
#endif // wxUSE_MENUS