Make accelerators work for menu items created in the code too

The previous commit fixed accelerators support in wxQt for the items
created in XRC, but not for those created directly in the code, as
wxMenuItem::SetItemLabel() is not called in this case.

Refactor the code to extract UpdateShortcutsFromLabel() from
SetItemLabel() and call the new function both from there and from
wxMenuItem ctor, to ensure that the accelerators are taken into account
in any case.

This commit is best viewed with "git diff --color-moved".

See https://github.com/wxWidgets/wxWidgets/pull/1544
This commit is contained in:
Vadim Zeitlin
2019-09-27 13:44:55 +02:00
parent a6efd027da
commit 3a918864f9
2 changed files with 25 additions and 14 deletions

View File

@@ -12,6 +12,7 @@
#include "wx/bitmap.h"
class QAction;
class wxQtAction;
class WXDLLIMPEXP_FWD_CORE wxMenu;
@@ -41,7 +42,7 @@ public:
private:
// Qt is using an action instead of a menu item.
QAction *m_qtAction;
wxQtAction *m_qtAction;
wxBitmap m_bitmap;
wxDECLARE_DYNAMIC_CLASS( wxMenuItem );