Custom Button Toggling (Blue Highlight)

Custom Button Toggling (Blue Highlight)

Anonymous
Not applicable
1,491 Views
5 Replies
Message 1 of 6

Custom Button Toggling (Blue Highlight)

Anonymous
Not applicable

Hi there,

 

I'm wondering how I go about making a toggle button that shows the blue background highlight while the button effect is toggled "on."

 

For example, I have a "Affect Pivot Only Toggle" button with a custom icon that I made. I expected it to remain blue when the toggle is on, but it only turns blue during the button "down" state. There is no way to tell if the pivot only mode is on, unless I go to the Hierarchy tab - which defeats the purpose of the shortcut button.

 

Any way to accomplish this? It seems that these buttons are Macros, so maybe there would be a way to create a new macro script that performed the same function but also changed the button state? But I would also want the button state to change if the "Affect Pivot Only" toggle was enabled in some other fashion, such as the Hierarchy tab.

 

Thanks!

0 Likes
Accepted solutions (1)
1,492 Views
5 Replies
Replies (5)
Message 2 of 6

Swordslayer
Advisor
Advisor
Accepted solution

What button are we talking about, is that a toolbar button? If so, then yes, you have to modify the macroscript and add isChecked event handler:

 

macroScript example category:"Examples" tooltip:"Toggle Affect Pivot"
(
	on isChecked do maxOps.pivotMode == #pivotOnly
	on execute do maxOps.pivotMode = if maxOps.pivotMode == #pivotOnly then #none else #pivotOnly
)
0 Likes
Message 3 of 6

Anonymous
Not applicable

Okay thank you for that. That is mostly what I am looking for, except for one feature:

 

I would like the button to function as "checked" if the user clicks the "Affect Pivot Only" button in the Hierarchy tab as well. Currently with your solution the button works, but does not highlight when I use a different method of setting the "Affect Pivot Only" toggle.

 

Thanks!

0 Likes
Message 4 of 6

Swordslayer
Advisor
Advisor

It works that way, though you will only notice if toolbar update gets triggered (either when doing something else in the toolbar or you can force it with a updateToolbarButtons() call).

0 Likes
Message 5 of 6

Anonymous
Not applicable

Okay that makes sense... is there a way to perform the updateToolbarButtons() function whenever that button is clicked in the Hierarchy tab?

0 Likes
Message 6 of 6

Swordslayer
Advisor
Advisor

UI-wise, not really. Not sure if there's a callback that would catch the maxOps.pivotMode change, try and test a few of them - if so, it would be a clean and universal solution. You could also have a timer that would compare the current maxOps.pivotMode with the state on previous tick - that would work but not sure if it's worth it.

0 Likes