ZBrushCentral

Can I make a button that does something different if the user holds ALT when clicking?

Pretty much what the title says. thanks!

The answer is, not really. This code below will work but only if the zscript is loaded. In other words, if you make it into a plugin then the first press of the button won’t register the ALT key if it is held, the second press will. This is because the [Sleep] function only works if the plugin is loaded and if the button press is what loads the plugin then the Sleep hasn’t got going yet.

It’s a shame because it’s nice functionality but I avoid it these days because it’s unreliable.

[VarDef,keyOnMouseDown,0]

[Sleep,0.001,
	[If,SleepResult==4,//waits for keypress
		[VarSet,keyOnMouseDown,
			[IGet,preferences:utilities:viewkeyboardstatus]
		]
	]
	[SleepAgain],4,sleepResult
]

[IButton,"Press","Press",
[If,((KeyOnMouseDown)&1024)==1024,
[Note,"You pressed the ALT key"]//commands for Alt keypress on click button
,//else
[Note,"You DIDN'T press the ALT key"]//commands for straight mousedown on button
]//end if
]

-Marcus