Fixed menu event propogation to be consistent across platforms, and
with the docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19967 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -199,7 +199,8 @@ bool wxFrameBase::ProcessCommand(int id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetEventHandler()->ProcessEvent(commandEvent);
|
GetEventHandler()->ProcessEvent(commandEvent);
|
||||||
|
return TRUE;
|
||||||
#else // !wxUSE_MENUS
|
#else // !wxUSE_MENUS
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif // wxUSE_MENUS/!wxUSE_MENUS
|
#endif // wxUSE_MENUS/!wxUSE_MENUS
|
||||||
|
@@ -172,7 +172,8 @@ static void gtk_menu_open_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_OPEN, -1 );
|
wxMenuEvent event( wxEVT_MENU_OPEN, -1 );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
|
if (handler && handler->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxWindow *win = menu->GetInvokingWindow();
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
@@ -700,6 +701,13 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
if (!menu->IsEnabled(id))
|
if (!menu->IsEnabled(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( menu->IsAttached() ) // is this menu on a menubar?
|
||||||
|
{
|
||||||
|
wxFrame* frame = menu->GetMenuBar()->GetFrame();
|
||||||
|
frame->ProcessCommand(id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
wxMenuItem* item = menu->FindChildItem( id );
|
wxMenuItem* item = menu->FindChildItem( id );
|
||||||
wxCHECK_RET( item, wxT("error in menu item callback") );
|
wxCHECK_RET( item, wxT("error in menu item callback") );
|
||||||
|
|
||||||
@@ -724,6 +732,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
|
menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -744,7 +753,8 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
|
if (handler && handler->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxWindow *win = menu->GetInvokingWindow();
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
@@ -769,7 +779,8 @@ static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
|
if (handler && handler->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxWindow *win = menu->GetInvokingWindow();
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
|
@@ -172,7 +172,8 @@ static void gtk_menu_open_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_OPEN, -1 );
|
wxMenuEvent event( wxEVT_MENU_OPEN, -1 );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
|
if (handler && handler->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxWindow *win = menu->GetInvokingWindow();
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
@@ -700,6 +701,13 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
if (!menu->IsEnabled(id))
|
if (!menu->IsEnabled(id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( menu->IsAttached() ) // is this menu on a menubar?
|
||||||
|
{
|
||||||
|
wxFrame* frame = menu->GetMenuBar()->GetFrame();
|
||||||
|
frame->ProcessCommand(id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
wxMenuItem* item = menu->FindChildItem( id );
|
wxMenuItem* item = menu->FindChildItem( id );
|
||||||
wxCHECK_RET( item, wxT("error in menu item callback") );
|
wxCHECK_RET( item, wxT("error in menu item callback") );
|
||||||
|
|
||||||
@@ -724,6 +732,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
|
menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -744,7 +753,8 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
|
if (handler && handler->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxWindow *win = menu->GetInvokingWindow();
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
@@ -769,7 +779,8 @@ static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
|
wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
wxEvtHandler* handler = menu->GetEventHandler();
|
||||||
|
if (handler && handler->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxWindow *win = menu->GetInvokingWindow();
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
|
@@ -2349,20 +2349,12 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr )
|
|||||||
void wxApp::MacHandleMenuCommand( wxUint32 id )
|
void wxApp::MacHandleMenuCommand( wxUint32 id )
|
||||||
{
|
{
|
||||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
wxMenu* menu = NULL ;
|
wxFrame* frame = mbar->GetFrame();
|
||||||
wxMenuItem* item = NULL ;
|
wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
|
||||||
if ( mbar )
|
if ( frame )
|
||||||
{
|
{
|
||||||
item = mbar->FindItem( id , &menu ) ;
|
frame->ProcessCommand(id);
|
||||||
}
|
}
|
||||||
wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
|
|
||||||
|
|
||||||
if (item->IsCheckable())
|
|
||||||
{
|
|
||||||
item->Check( !item->IsChecked() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TARGET_CARBON
|
#if !TARGET_CARBON
|
||||||
|
@@ -2349,20 +2349,12 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr )
|
|||||||
void wxApp::MacHandleMenuCommand( wxUint32 id )
|
void wxApp::MacHandleMenuCommand( wxUint32 id )
|
||||||
{
|
{
|
||||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
wxMenu* menu = NULL ;
|
wxFrame* frame = mbar->GetFrame();
|
||||||
wxMenuItem* item = NULL ;
|
wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
|
||||||
if ( mbar )
|
if ( frame )
|
||||||
{
|
{
|
||||||
item = mbar->FindItem( id , &menu ) ;
|
frame->ProcessCommand(id);
|
||||||
}
|
}
|
||||||
wxCHECK_RET( item != NULL && menu != NULL && mbar != NULL, wxT("error in menu item callback") );
|
|
||||||
|
|
||||||
if (item->IsCheckable())
|
|
||||||
{
|
|
||||||
item->Check( !item->IsChecked() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TARGET_CARBON
|
#if !TARGET_CARBON
|
||||||
|
Reference in New Issue
Block a user