Correction to my new menu code: handle submenus on menubar menus

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19970 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2003-04-03 21:01:52 +00:00
parent 6568015373
commit 02822c8cdf
2 changed files with 28 additions and 4 deletions

View File

@ -701,11 +701,23 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
if (!menu->IsEnabled(id))
return;
if ( menu->IsAttached() ) // is this menu on a menubar?
// Is this menu on a menubar? (possibly nested)
wxFrame* frame = NULL;
wxMenu* pm = menu;
while ( pm && !frame )
{
if ( pm->IsAttached() )
frame = pm->GetMenuBar()->GetFrame();
else
pm = pm->GetParent();
}
// If it is then let the frame send the event
if (frame)
{
wxFrame* frame = menu->GetMenuBar()->GetFrame();
frame->ProcessCommand(id);
}
// otherwise let the menu have it
else
{
wxMenuItem* item = menu->FindChildItem( id );

View File

@ -701,11 +701,23 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
if (!menu->IsEnabled(id))
return;
if ( menu->IsAttached() ) // is this menu on a menubar?
// Is this menu on a menubar? (possibly nested)
wxFrame* frame = NULL;
wxMenu* pm = menu;
while ( pm && !frame )
{
if ( pm->IsAttached() )
frame = pm->GetMenuBar()->GetFrame();
else
pm = pm->GetParent();
}
// If it is then let the frame send the event
if (frame)
{
wxFrame* frame = menu->GetMenuBar()->GetFrame();
frame->ProcessCommand(id);
}
// otherwise let the menu have it
else
{
wxMenuItem* item = menu->FindChildItem( id );