Selectmore by clicking buttons

Hi everyone, I´m trying to do some kind of picker based on "bipedsel" but really basic.
Let´s say that I have this:

rollout test "Untitled" width:141 height:181
(
	button btnHead "head" pos:[54,16] width:31 height:25
	button btnspine1 "spine1" pos:[43,46] width:52 height:25
	button btnspine2 "spine2" pos:[43,75] width:52 height:25
	button btn4pelvis "Pelvis" pos:[43,104] width:52 height:12
	button btnLegL "LegL" pos:[47,121] width:17 height:43
	button btnLegR "LegR" pos:[70,121] width:17 height:43
	button btnLarm1 "Larm1" pos:[20,46] width:17 height:43
	button btnLarm2 "Larm2" pos:[17,94] width:22 height:18
	button btnRarm1 "Rarm1" pos:[102,46] width:17 height:43
	button btnRarm2 "Rarm2" pos:[99,94] width:22 height:18
 
on btnHead pressed do (select $Box001)
on btnspine1 pressed do (select $Box002)
on btnspine2 pressed do (select $Box003)
on btn4pelvis pressed do (select $Box004)	
on btnLegL pressed do (select $Box005)	
on btnLegR pressed do (select $Box006)	
on btnLarm1 pressed do (select $Box007)	
on btnLarm2 pressed do (select $Box008)	
on btnRarm1 pressed do (select $Box009)	
on btnRarm2 pressed do (select $Box010)	
)
createdialog test

Really symple uh, but I´m fighting to get adding selections with Ctrl and also deselecting them.

I know that this short code do it from bipedsel:

fn fn_sel_obj a b =
	(
		try
		(
			args = biped.getNode bs_biped a link:b
			if keyboard.controlPressed then
			(
				if args.isSelected then (deselect args) else (selectMore args)
			)
			else select args
		) catch()
	)

But I don´t know how to implement it. I need args be all the buttons (I mean: args = buttons?)
I don´t know if it is a hard question, I hope you can help me.

Thanks in advance.

Comments

Comment viewing options

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

isSelected is methods

isSelected is one of methods of node, to check if current node you define is selected ...lets say you got box2 and you select it and then you type this on maxscript listener

$box2.isSelected 
-- it will result boolean true...
-- but if you are not select it then it'll return false instead

note: node can be any kind of objects
Also I prefer not using selectmore if in large object, it's slow when the object is not selected but , instead use select directly , it'll deselect your current object and directly select next object you define....

example

--this case you already had $box2 selected , and you want 
--to select $box3, instead using selectmore just use
select $box3
-- it'll deselect $box2 and instantly select $box3

but how you select the previous one ,ex:$box2.....?

Hope someone correct me if Im wrong

Comment viewing options

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