Make wxEVT_MENU_HIGHLIGHT generation when there is no highlighted item
consistent across all the major ports: use wxID_NONE instead of wxID_ANY
in wxGTK and send these events, which were previously not sent at all in
this case, in wxOSX.

See https://github.com/wxWidgets/wxWidgets/pull/1637
This commit is contained in:
Vadim Zeitlin
2019-11-05 20:03:36 +01:00
6 changed files with 20 additions and 7 deletions

View File

@@ -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
-----------------------------------------------------

View File

@@ -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.

View File

@@ -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);
}
}

View File

@@ -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();

View File

@@ -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 );
}
}
}

View File

@@ -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());
}