开发者

How to disable/inactive some of the GtkMenu Items

I am trying to disable/inactive some of menu items under GTK+. I have created Me开发者_开发百科nu In GTK+Glade under C, and on some external event I need to disable some of the menu options.

How can I do this?


You can use gtk_widget_set_sensitive(menuitem, true/false) to disable or enable the menu item widget.

Alternatively, if you used GtkUiManager and GtkAction to build the menu, use gtk_action_set_sensitive() instead.


Using:

gtk_widget_set_sensitive (menuitem,FALSE); // to gray-out
gtk_widget_set_sensitive (menuitem,TRUE); //to enable


Use with Vala + Gtk:

Gtk.Button play = new Gtk.Button.with_mnemonic("Play");
play.set_sensitive(false); // to gray-out


There is also a checkbox inside Glade to disable the menu item:

Select your menu item --> Common --> Widget Flags --> Uncheck "Sensitive"

How to disable/inactive some of the GtkMenu Items

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜