diff --git a/docs/changes.txt b/docs/changes.txt index d2f2fe1a07..84e5e94c60 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -83,6 +83,10 @@ 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 wxID_NONE item ID for wxEVT_MENU_HIGHLIGHT events sent when + there is no highlighted menu item, instead of wxID_ANY used before, for + consistency with wxMSW. + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/interface/wx/menuitem.h b/interface/wx/menuitem.h index 16fe5c282a..143ac6b3bd 100644 --- a/interface/wx/menuitem.h +++ b/interface/wx/menuitem.h @@ -31,8 +31,10 @@ 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, highlighting has been removed from the previously + highlighted menu item and there is no highlighted item any more. + 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. 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(); diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 0f600ea2c4..05a377726e 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 ); + } } } 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()); }