Checkbox Menu item
-
Is it possible to create an menu item which you can toggle on/off. A checkbox menu item? Like the Hidden Geometry menu item under the View menu?
-
Sure can, Thomas. This contrived example works. Just change the global $f to true in the Ruby Console to see the checkmark in the menu.
$f = false def hi puts "hi" end menu = UI.menu("Plugins") item = menu.add_item("Hi") { hi() } def vp return MF_CHECKED if $f == true return MF_UNCHECKED if $f == false end menu.set_validation_proc(item) { vp }
-
Great! Thanks!
-
btw, where did you find them constants?
-
in UI::Command, where else?
@unknownuser said:
Your procedure should return either MF_ENABLED, MF_DISABLED, MF_CHECKED, MF_UNCHECKED, or MF_GRAYED.
-
I see. I never looked that that class yet. I just saw the UI::Menu class and thought that was the one. And there was nothing on the constants there.
It says that UI.Command is the preferred way to add toolbars and menu items, but why? what's the difference and benefit?
Advertisement