Toggle toolbar button pressed state

Is there any way to toggle the toolbar button’s pressed state to ‘PRESSED’ or ‘UNPRESSED’.
When I do Sketchup.active_model.select_tool(tool) the button associated to ‘tool’ is not changing to ‘PRESSED’ state.

Look up the “Command#set_validation_proc” method.

I have used the “Command#set_validation_proc” to gray and check right click menu options for a tool that I developed.

I have noticed on Windows that when a toolbar button is configured to run a simple Ruby program, then the button pops up immediately. If the button has code that does:

`Sketchup.active_model.select_tool(my_tool)`

Where “my_tool” is a Tool class object that I defined, then the button stays down until I exit my tool.

@amruthrajv:
Are you on Mac or Windows?
What methods does your “tool” object support?

add on, you can look for set_validation_proc method using MF_ENABLED, MF_DISABLED and MF_GRAYED states - however, on the Mac this toolbar MF status not really working well on SU2019…
Win machines are fine.
I also have the problem where I try to iterate between 2 functions every time when this button is pressed.
Who can help? LOL

We are already way ahead of you … see this long thread it answers your questions …

1 Like

haha true, thanks Dan! :slight_smile:

1 Like