Notifications
Clear all

[Closed] two functions for a button ??

is it possible to script two functions for one button ??

if yes, how to implement a mouse tool like :

right click – pick an object on the scene an assing it to the button
left click – quick select this object on the scene

thanks.

11 Replies

look up ‘button’ in the maxscript reference and you’ll find that buttons have 2 event handlers. One for left click (on <button> pressed do) and one for right click (on <button> rightclick do)

EDIT: after reading your post again I think you’ll want to use the pickbutton rather than a standard button. pickbutton’s have 2 event handlers too. ‘picked’ and ‘rightclick’. Check the reference!

cool man, thanks !

i´ll check it and back soon with some inputs.

EDIT:

but let say if i need to select/deselect a bunch, by using CTRL/ALT ?
is it possible to do an array of buttons that stores objects ?
or is more simple to make a collection first, instead reference object to a button ?

i´m kinda lost…
oO?

You could make local variables for the rollout, one for each button, that will store whatever you need… then when you click or rightclick the button, you can store whatever in those variables.

Also a great time to use a struct or array.

thanks all guys !

i´ll be doing more research.

Look up “keyboard” in the MaxScript help file. In the button event handler just use some if/then statements to check for key presses and then run what you want.

on theButton pressed do
(
if keyboard.controlPressed (select stuff)
else if keyboard.altPressed (deselect stuff)
)

I use this all the time to add extra functionality to buttons, but it may or may not work for what you’re describing here.

you could also use an imgtag to function like a button and expose the extra mouse event handlers that it uses.

cool !
can i define a function and aplly it to the button ?

example:


 fn Kboard_pick = 
 if keyboard.controlPressed (select stuff)
  else if keyboard.altPressed (deselect stuff)
 
 on theButton pressed do Kboard_pick
 

i looked Up on the HELP abut Keyboard, but i didn´t seen any coments about using it with rightclick…

can you show me a example of it, please ?

thks.=)

1 Reply
(@jhaywood)
Joined: 11 months ago

Posts: 0

Yeah, you can do that. In fact, this is the preferred way to create tools. When you need to change what the button does, you just work on the function and don’t have to get into the rollout code. Keeping your UI code seperate from your execution code is a good practice.

sorry,
what do you mean STRUCT ?

Page 1 / 2