Merge branch 'menu_highlight_event' of https://github.com/imciner2/wxWidgets
Set menu object for the menu highlight events too. See https://github.com/wxWidgets/wxWidgets/pull/1506
This commit is contained in:
@@ -3295,7 +3295,7 @@ public:
|
|||||||
@class wxDisplayChangedEvent
|
@class wxDisplayChangedEvent
|
||||||
|
|
||||||
A display changed event is sent to top-level windows when the display resolution has changed.
|
A display changed event is sent to top-level windows when the display resolution has changed.
|
||||||
|
|
||||||
This event is currently emitted under Windows only.
|
This event is currently emitted under Windows only.
|
||||||
|
|
||||||
@beginEventTable{wxDisplayChangedEvent}
|
@beginEventTable{wxDisplayChangedEvent}
|
||||||
@@ -3309,7 +3309,7 @@ public:
|
|||||||
@category{events}
|
@category{events}
|
||||||
|
|
||||||
@see wxDisplay
|
@see wxDisplay
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class wxDisplayChangedEvent : public wxEvent
|
class wxDisplayChangedEvent : public wxEvent
|
||||||
{
|
{
|
||||||
@@ -4501,13 +4501,16 @@ public:
|
|||||||
wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0, wxMenu* menu = NULL);
|
wxMenuEvent(wxEventType type = wxEVT_NULL, int id = 0, wxMenu* menu = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the menu which is being opened or closed.
|
Returns the menu which is being opened or closed, or the menu containing
|
||||||
|
the highlighted item.
|
||||||
This method can only be used with the @c OPEN and @c CLOSE events.
|
|
||||||
|
|
||||||
Note that the returned value can be @NULL if the menu being opened
|
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
|
doesn't have a corresponding wxMenu, e.g. this happens when opening the
|
||||||
system menu in wxMSW port.
|
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;
|
wxMenu* GetMenu() const;
|
||||||
|
|
||||||
|
@@ -1235,19 +1235,21 @@ void MyFrame::LogMenuOpenCloseOrHighlight(const wxMenuEvent& event, const wxStri
|
|||||||
|
|
||||||
if ( event.GetEventType() == wxEVT_MENU_HIGHLIGHT )
|
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();
|
msg << " (";
|
||||||
if ( menu )
|
}
|
||||||
{
|
|
||||||
msg << " (menu with title \"" << menu->GetTitle() << "\")";
|
wxMenu* const menu = event.GetMenu();
|
||||||
}
|
if ( menu )
|
||||||
else
|
{
|
||||||
{
|
msg << "menu with title \"" << menu->GetTitle() << "\")";
|
||||||
msg << " (no menu)";
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
msg << "no menu provided)";
|
||||||
}
|
}
|
||||||
|
|
||||||
msg << ".";
|
msg << ".";
|
||||||
|
@@ -560,7 +560,7 @@ static void menuitem_select(GtkWidget*, wxMenuItem* item)
|
|||||||
if (!item->IsEnabled())
|
if (!item->IsEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item->GetId());
|
wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item->GetId(), item->GetMenu());
|
||||||
DoCommonMenuCallbackCode(item->GetMenu(), event);
|
DoCommonMenuCallbackCode(item->GetMenu(), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -575,7 +575,7 @@ static void menuitem_deselect(GtkWidget*, wxMenuItem* item)
|
|||||||
if (!item->IsEnabled())
|
if (!item->IsEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
|
wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, -1, item->GetMenu());
|
||||||
DoCommonMenuCallbackCode(item->GetMenu(), event);
|
DoCommonMenuCallbackCode(item->GetMenu(), event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -645,7 +645,7 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
if (!menu->IsEnabled(id))
|
if (!menu->IsEnabled(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id, menu );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
wxEvtHandler* handler = menu->GetEventHandler();
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
@@ -673,7 +673,7 @@ static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
if (!menu->IsEnabled(id))
|
if (!menu->IsEnabled(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1, menu );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
wxEvtHandler* handler = menu->GetEventHandler();
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
|
@@ -385,7 +385,7 @@ void wxMenuItemArmCallback (Widget WXUNUSED(w), XtPointer clientData,
|
|||||||
{
|
{
|
||||||
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
||||||
{
|
{
|
||||||
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
|
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId(), item->GetMenu());
|
||||||
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||||
|
|
||||||
item->GetMenuBar()->GetMenuBarFrame()
|
item->GetMenuBar()->GetMenuBarFrame()
|
||||||
@@ -405,7 +405,7 @@ wxMenuItemDisarmCallback (Widget WXUNUSED(w), XtPointer clientData,
|
|||||||
{
|
{
|
||||||
// TODO: not sure this is correct, since -1 means something
|
// TODO: not sure this is correct, since -1 means something
|
||||||
// special to event system
|
// special to event system
|
||||||
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
|
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1, item->GetMenu());
|
||||||
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||||
|
|
||||||
item->GetMenuBar()->GetMenuBarFrame()
|
item->GetMenuBar()->GetMenuBarFrame()
|
||||||
|
@@ -2420,8 +2420,9 @@ wxWindowMSW::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
|
|||||||
if ( flags & (MF_POPUP | MF_SEPARATOR) )
|
if ( flags & (MF_POPUP | MF_SEPARATOR) )
|
||||||
item = wxID_NONE;
|
item = wxID_NONE;
|
||||||
|
|
||||||
wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
|
wxMenu* menu = MSWFindMenuFromHMENU(hMenu);
|
||||||
if ( wxMenu::ProcessMenuEvent(MSWFindMenuFromHMENU(hMenu), event, this) )
|
wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item, menu);
|
||||||
|
if ( wxMenu::ProcessMenuEvent(menu, event, this) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// by default, i.e. if the event wasn't handled above, clear the status bar
|
// by default, i.e. if the event wasn't handled above, clear the status bar
|
||||||
|
Reference in New Issue
Block a user