From dcac98d7e8ad73edb485b9ca75fa2d574c003501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Mon, 28 May 2018 15:41:32 +0200 Subject: [PATCH] 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. --- src/msw/textctrl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 686435b620..19bf91424b 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -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