diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index dc12c62e98..88eb8cf728 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -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 ); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index dc12c62e98..88eb8cf728 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -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 );