Accelerators stop responding when menubar gets hidden

不问归期 提交于 2019-12-13 19:07:13

问题


I have a glade-based UI for gtk3, and I set accelerators fields for several menuitems. I'm not sure what GtkBuilder does exactly behind the scenes when it's loading the glade file (use a global GtkAccelGroup?), but the end result is, when I hide the menubar, the accelerator shortcuts stop working.

I'm wondering whether there is a way of getting the accelerators working even when the menu is not visible, while still sticking to glade as much as possible.


回答1:


Maybe you can try to stick the accelerators not to the menu, but one level higher in your application, for example the window? In my own application I do it like this.

accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (pad), accel_group);

pad->priv->menu = menu_get_popup_no_highlight (pad, accel_group);
pad->priv->highlight_menu = menu_get_popup_highlight (pad, accel_group);

gtk_accel_group_connect (accel_group, GDK_KEY_Q, GDK_CONTROL_MASK, 0, g_cclosure_new_swap (G_CALLBACK (xpad_app_quit), pad, NULL));

The two menu assignments have their own accelerators which are working even when not visible.

Does this help you?



来源:https://stackoverflow.com/questions/19707775/accelerators-stop-responding-when-menubar-gets-hidden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!