From 15909a5f7c0b7efe8ea3dc1ebced54a76504c5f4 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 5 Nov 2019 08:54:54 +0000 Subject: [PATCH 1/5] OSX: If no menu item given, use wxID_NONE as item ID --- src/osx/menu_osx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osx/menu_osx.cpp b/src/osx/menu_osx.cpp index 75251bc06a..40fd87d164 100644 --- a/src/osx/menu_osx.cpp +++ b/src/osx/menu_osx.cpp @@ -379,7 +379,7 @@ bool wxMenu::HandleCommandProcess( wxMenuItem* item, wxWindow* senderWindow ) void wxMenu::HandleMenuItemHighlighted( wxMenuItem* item ) { - int menuid = item ? item->GetId() : 0; + int menuid = item ? item->GetId() : wxID_NONE; wxMenuEvent wxevent(wxEVT_MENU_HIGHLIGHT, menuid, this); ProcessMenuEvent(this, wxevent, GetWindow()); } From 11991137e1042043d8a4c062e28541117398dd44 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 5 Nov 2019 08:55:39 +0000 Subject: [PATCH 2/5] Send EVT_MENU_HIGHLIGHT when menu item is unhighlighted On OSX this only happens if no new menu item is being highlighted. --- src/osx/cocoa/menu.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 0f600ea2c4..1ee36ad60d 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -127,15 +127,22 @@ wxMenuImpl* menuimpl = [menu implementation]; if ( menuimpl ) { + wxMenuItem* menuitem = nullptr; wxMenu* wxpeer = (wxMenu*) menuimpl->GetWXPeer(); + if ( [ item isKindOfClass:[wxNSMenuItem class] ] ) { wxMenuItemImpl* menuitemimpl = (wxMenuItemImpl*) [ (wxNSMenuItem*) item implementation ]; - if ( wxpeer && menuitemimpl ) + if ( menuitemimpl ) { - wxpeer->HandleMenuItemHighlighted( menuitemimpl->GetWXPeer() ); + menuitem = menuitemimpl->GetWXPeer(); } } + + if ( wxpeer ) + { + wxpeer->HandleMenuItemHighlighted( menuitem ); + } } } From 790c1818cb8704c133414cf149f4f94db3176c5b Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 5 Nov 2019 09:15:55 +0000 Subject: [PATCH 3/5] Update menuitem docs with unhighlight event --- interface/wx/menuitem.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/interface/wx/menuitem.h b/interface/wx/menuitem.h index 16fe5c282a..0fa542b2d1 100644 --- a/interface/wx/menuitem.h +++ b/interface/wx/menuitem.h @@ -31,8 +31,9 @@ A menu has been just closed. This type of event is sent as wxMenuEvent. @event{EVT_MENU_HIGHLIGHT(id, func)} - The menu item with the specified id has been highlighted: used to show - help prompts in the status bar by wxFrame + The menu item with the specified id has been highlighted. If the id is wxID_NONE, a + menu item has ben unhighlighted. This is used by wxFrame to show help prompts in + the status bar This type of event is sent as wxMenuEvent. @event{EVT_MENU_HIGHLIGHT_ALL(func)} A menu item has been highlighted, i.e. the currently selected menu item has changed. From 3a668b4d0a439a619f7831ebd303f8d457feef70 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 5 Nov 2019 12:09:26 +0000 Subject: [PATCH 4/5] GTK: Use wxID_NONE for unhighlight events --- src/gtk/menu.cpp | 2 +- src/gtk1/menu.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 89976006ae..72432005e0 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -575,7 +575,7 @@ static void menuitem_deselect(GtkWidget*, wxMenuItem* item) if (!item->IsEnabled()) return; - wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, -1, item->GetMenu()); + wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, wxID_NONE, item->GetMenu()); DoCommonMenuCallbackCode(item->GetMenu(), event); } } diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 269972c499..1c2a76a344 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -673,7 +673,7 @@ static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu ) if (!menu->IsEnabled(id)) return; - wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1, menu ); + wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, wxID_NONE, menu ); event.SetEventObject( menu ); wxEvtHandler* handler = menu->GetEventHandler(); From 11f8d9d478bb121c58002e11c29c25a270dabca9 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 5 Nov 2019 12:09:51 +0000 Subject: [PATCH 5/5] Document unhighlight event changes --- docs/changes.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index d2f2fe1a07..192bff1e75 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -83,6 +83,9 @@ Changes in behaviour not resulting in compilation errors coordinates, e.g. returned by wxWindow::GetSize() by GetContentScaleFactor() before using them with OpenGL functions. +- wxGTK now uses the wxID_NONE item ID inside EVT_MENU_HIGHLIGHT events sent when + the menu item is unhighlighted (it used to use wxID_ANY). + Changes in behaviour which may result in build errors ----------------------------------------------------- @@ -143,6 +146,9 @@ Changes in behaviour which may result in build errors 3.1.4: (released ????-??-??) ---------------------------- +wxOSX: + +- Send EVT_MENU_HIGHLIGHT events when menu items are unhighlighted 3.1.3: (released 2019-10-28) ----------------------------