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?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement