How can I make checkbutton swiching off by pressing right mouse button ?

Hi!)

While I pressing checkbutton it loads the macros,
if i press right mousebutton macros stops working but checkbutton stays on.
Can it be switched off by pressing it twice.
How can I make checkbutton swiching off by pressing right mouse button ?

Thank you in advance

rollout RL_Test "Test"
(

checkButton 'ckb01' "Swift Loop" width:74 height:22 align:#center

on ckb01 changed state do

macros.run "PolyTools" "SwiftLoop"

)
createDialog RL_Test

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

If you want to un-check checkbutton when you rightclick in a viewport then there's no easy way to do it as far as I know.

But while SwiftLoop mode is active, bottom status panel shows a text 'Mouse Tool'.
Algorithm is pretty simple
1. start PolyToolsPolyDraw.SwiftLoop()
2. Find a hwnd handle of UI element with title 'Mouse Tool'
3. if hwnd is found Start a timer else set checked back to false since SwiftLoop isn't active

on each timer tick
check if this UI element changed its text to something different
if text is no longer equal to 'Mouse Tool' then user rightclicked or somehow disabled SwiftLoop mode. Stop timer. Set checkbutton state to checked = false

statusPanelHWND = (dotNetClass "Autodesk.Max.GlobalInterface").Instance.CoreInterface7.StatusPanelHWND
for child in windows.getChildrenHWND statusPanelHWND do format "%\n" child

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.