diff --git a/src/gui/toolbarMenubar/AbstractItem.cpp b/src/gui/toolbarMenubar/AbstractItem.cpp index b87db852..274e5782 100644 --- a/src/gui/toolbarMenubar/AbstractItem.cpp +++ b/src/gui/toolbarMenubar/AbstractItem.cpp @@ -8,6 +8,7 @@ AbstractItem::AbstractItem(string id, ActionHandler* handler, ActionType action, this->action = action; this->menuitem = NULL; this->checkMenuItem = false; + this->ignoreNextCheckMenuEvent = false; this->menuSignalHandler = 0; this->group = GROUP_NOGROUP; this->enabled = true; @@ -64,6 +65,10 @@ void AbstractItem::actionSelected(ActionGroup group, ActionType action) { if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(this->menuitem)) != itemActive) { + if (checkMenuItem) + { + ignoreNextCheckMenuEvent = true; + } gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(this->menuitem), itemActive); } } @@ -135,6 +140,12 @@ void AbstractItem::activated(GdkEvent* event, GtkMenuItem* menuitem, GtkToolButt selected = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(toolbutton)); } + if (checkMenuItem && ignoreNextCheckMenuEvent) + { + ignoreNextCheckMenuEvent = false; + return; + } + actionPerformed(action, group, event, menuitem, toolbutton, selected); } @@ -142,12 +153,6 @@ void AbstractItem::actionPerformed(ActionType action, ActionGroup group, GdkEvent* event, GtkMenuItem* menuitem, GtkToolButton* toolbutton, bool selected) { - if (checkMenuItem) - { - printf("-->%i\n", selected); - return; - } - handler->actionPerformed(action, group, event, menuitem, toolbutton, selected); } diff --git a/src/gui/toolbarMenubar/AbstractItem.h b/src/gui/toolbarMenubar/AbstractItem.h index 065319b9..16399d8b 100644 --- a/src/gui/toolbarMenubar/AbstractItem.h +++ b/src/gui/toolbarMenubar/AbstractItem.h @@ -69,6 +69,11 @@ private: */ bool checkMenuItem; + /** + * ignore event if the menu is programmatically changed + */ + bool ignoreNextCheckMenuEvent; + /** * Keep the state for toggle / radio menu handling */