X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4608a8af3735907d923c57311eae957a40ff0eb..13588544c5fd50e15240c30b0d0e0b533ffe7d1a:/src/gtk/menu.cpp diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index e30e13f7b8..5c17e2c985 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -146,13 +146,15 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) { menu->SetInvokingWindow( win ); -#if (GTK_MINOR_VERSION > 0) +#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0) wxWindow *top_frame = win; while (top_frame->GetParent() && !(top_frame->IsTopLevel())) top_frame = top_frame->GetParent(); /* support for native hot keys */ - gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); + GtkObject *obj = GTK_OBJECT(top_frame->m_widget); + if ( !g_slist_find( menu->m_accel->attach_objects, obj ) ) + gtk_accel_group_attach( menu->m_accel, obj ); #endif wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); @@ -174,7 +176,9 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) top_frame = top_frame->GetParent(); /* support for native key accelerators indicated by underscroes */ - gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) ); + GtkObject *obj = GTK_OBJECT(top_frame->m_widget); + if ( !g_slist_find( m_accel->attach_objects, obj ) ) + gtk_accel_group_attach( m_accel, obj ); #endif wxMenuList::Node *node = m_menus.GetFirst(); @@ -313,6 +317,9 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) if ( !GtkAppend(menu, title) ) return FALSE; + if (pos+1 >= m_menus.GetCount()) + return TRUE; + GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); gpointer data = g_list_last(menu_shell->children)->data; menu_shell->children = g_list_remove(menu_shell->children, data); @@ -331,9 +338,6 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) { - if ( !wxMenuBarBase::Replace(pos, menu, title) ) - return (wxMenu*) NULL; - // remove the old item and insert a new one wxMenu *menuOld = Remove(pos); if ( menuOld && !Insert(pos, menu, title) ) @@ -637,9 +641,10 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) #if (GTK_MINOR_VERSION > 0) for ( const wxChar *pc = text.c_str(); *pc; pc++ ) { - if ( *pc == wxT('_') ) + if ( *pc == wxT('_') || *pc == wxT('&') ) { - // this is the escape character for GTK+ - skip it + // '_' is the escape character for GTK+ and '&' is the one for + // wxWindows - skip both of them continue; } @@ -867,6 +872,12 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) #endif // GTK 1.2/1.0 gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); + + // if adding a submenu to a menu already existing in the menu bar, we + // must set invoking window to allow processing events from this + // submenu + if ( m_invokingWindow ) + wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow); } else // a normal item {