Allow to add extra accelerators to wxMenuItem

These accelerators are not shown in wxMenuItem label, but still will
work.

Implement support for them in all major ports and XRC.

Co-Authored-By: Vadim Zeitlin <vadim@wxwidgets.org>
This commit is contained in:
Alexander Koshelev 2021-11-02 16:19:25 +03:00 committed by Vadim Zeitlin
parent e729791222
commit 0cd898975c
18 changed files with 375 additions and 33 deletions

View file

@ -23,6 +23,8 @@
#include "wx/windowid.h"
#include "wx/vector.h"
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
@ -122,6 +124,14 @@ public:
// set the accel for this item - this may also be done indirectly with
// SetText()
virtual void SetAccel(wxAcceleratorEntry *accel);
// add the accel to extra accels list
virtual void AddExtraAccel(const wxAcceleratorEntry& accel);
// return vector of extra accels. Implementation only.
const wxVector<wxAcceleratorEntry>& GetExtraAccels() const { return m_extraAccels; }
virtual void ClearExtraAccels() { m_extraAccels.clear(); }
#endif // wxUSE_ACCEL
#if WXWIN_COMPATIBILITY_2_8
@ -163,6 +173,10 @@ protected:
bool m_isChecked; // is checked?
bool m_isEnabled; // is enabled?
#if wxUSE_ACCEL
wxVector<wxAcceleratorEntry> m_extraAccels; // extra accels will work, but won't be shown in wxMenuItem title
#endif // wxUSE_ACCEL
// this ctor is for the derived classes only, we're never created directly
wxMenuItemBase(wxMenu *parentMenu = NULL,
int itemid = wxID_SEPARATOR,