fixes #86 and fixes #307

Menu and Toolbar handling have to be improved a little. And all have to
work together.
presentation
Andreas Butti 7 years ago
parent 17f56ea905
commit 7318b59a12
  1. 17
      src/gui/toolbarMenubar/AbstractItem.cpp
  2. 5
      src/gui/toolbarMenubar/AbstractItem.h

@ -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);
}

@ -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
*/

Loading…
Cancel
Save