From d846b244508a867f747cb83cd04ebc0b4c43b038 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 25 Aug 2019 16:25:55 +0200 Subject: [PATCH] Update menu event documentation and sample Update the documentation to reflect change to the GetMenu event working for all 3 menu events. Also update the sample to give the menu for the highlight event. --- interface/wx/event.h | 13 ++++++++----- samples/menu/menu.cpp | 24 +++++++++++++----------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/interface/wx/event.h b/interface/wx/event.h index 3b80a529fb..887ba564af 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -3295,7 +3295,7 @@ public: @class wxDisplayChangedEvent A display changed event is sent to top-level windows when the display resolution has changed. - + This event is currently emitted under Windows only. @beginEventTable{wxDisplayChangedEvent} @@ -3309,7 +3309,7 @@ public: @category{events} @see wxDisplay -*/ +*/ class wxDisplayChangedEvent : public wxEvent { @@ -4445,13 +4445,16 @@ public: wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0, wxMenu* menu = NULL); /** - Returns the menu which is being opened or closed. - - This method can only be used with the @c OPEN and @c CLOSE events. + Returns the menu which is being opened or closed, or the menu containing + the highlighted item. Note that the returned value can be @NULL if the menu being opened doesn't have a corresponding wxMenu, e.g. this happens when opening the system menu in wxMSW port. + + @remarks Since 3.1.3 this function can be used with @c OPEN, @c CLOSE + and @c HIGHLIGHT events. Before 3.1.3, this method can only be used + with the @c OPEN and @c CLOSE events. */ wxMenu* GetMenu() const; diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index 2302bbbf88..3d3f5c2e52 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -1235,19 +1235,21 @@ void MyFrame::LogMenuOpenCloseOrHighlight(const wxMenuEvent& event, const wxStri if ( event.GetEventType() == wxEVT_MENU_HIGHLIGHT ) { - msg << " (id=" << event.GetId() << ")"; + msg << " (id=" << event.GetId() << " in "; } - else // wxEVT_MENU_{OPEN,CLOSE} + else { - wxMenu* const menu = event.GetMenu(); - if ( menu ) - { - msg << " (menu with title \"" << menu->GetTitle() << "\")"; - } - else - { - msg << " (no menu)"; - } + msg << " ("; + } + + wxMenu* const menu = event.GetMenu(); + if ( menu ) + { + msg << "menu with title \"" << menu->GetTitle() << "\")"; + } + else + { + msg << "no menu provided)"; } msg << ".";