Notifications
Clear all

[Closed] Controlling mouse tools from a rollout??

I’m currently trying to set up a rollout with several buttons that each activate a different mouse tool. My problem is if I click on a tool button while a different tool is still running, it doesn’t activate because the old tool is still running. (Actually, it seems to work exactly ONCE, which seems very strange to me.)

So, I figured I could just write a stopTool method into each of the buttons to stop the other one, but it doesn’t want to work that way. I thought initially that it was just not possible to call the stopTool method from a rollout button, but after creating a button that specifically does that and nothing else, it works.

…wut? Nothing about this makes sense to me!

See example:

tool toolOne
(
	on freeMove do format "1
"
)

tool toolTwo
(
	on freeMove do format "2
"
)

rollout RO_Tools "Mouse Tools"
(
	button btn1 "Tool 1"
	button btn2 "Tool 2"
	button btn_Quit "Quit"
	
	on btn1 pressed do
	(
		stopTool toolTwo
		startTool toolOne
	)
	
	on btn2 pressed do
	(
		stopTool toolOne
		startTool toolTwo
	)
	
	on btn_Quit pressed do
	(
		stopTool toolOne
		stopTool toolTwo
	)
)
createDialog RO_Tools
19 Replies

Has anyone taken a look at this? I really can’t tell if I’m doing something wrong or if there is a bug in the program…

3 Replies
(@denist)
Joined: 11 months ago

Posts: 0

to stop any mouse tool just set max tool mode to select, move, or rotate.

(@malkalypse)
Joined: 11 months ago

Posts: 0

Am I doing this wrong? Because it’s not working for me…

try (destroyDialog RO_Tools) catch()

tool toolOne
(
	on start do format "starting tool 1
"
	on stop do format "stopping tool 1
"
)

tool toolTwo
(
	on start do	format "starting tool 2
"
	on stop do format "stopping tool 2
"
)

rollout RO_Tools "Mouse Tools"
(
	button btn1 "Tool 1"
	button btn2 "Tool 2"
	button btn_Quit "Quit"
	
	on btn1 pressed do
	(
		format "

pressed button 1
"
		max select
		startTool toolOne
	)
	
	on btn2 pressed do
	(
		format "

pressed button 2
"
		max select
		startTool toolTwo
	)
	
	on btn_Quit pressed do max select
)
createDialog RO_Tools
(@denist)
Joined: 11 months ago

Posts: 0

you do it wrong…
see toolmode.commandmode

Thanks Denis! I’ll definitely experiment with that. In the meantime, I just found another solution, which is to use checkbuttons instead of buttons. I actually like the checkbuttons better because you can see what you’re currently doing.

The only odd thing I’ve noticed about this script is that if you switch back and forth multiple times before stopping, it will run a whole bunch of stop handlers in a row (equal to the total number of clicks before turning off both tools or right-clicking.)

try (destroyDialog RO_Tools) catch()

tool toolOne
(
	on start do format "starting tool 1

"	
	on stop do format "stopping tool 1
"
)

tool toolTwo
(
	on start do format "starting tool 2

"
	on stop do format "stopping tool 2
"
)

rollout RO_Tools "Mouse Tools"
(
	checkButton chk1 "Tool 1"
	checkButton chk2 "Tool 2"
	
	on chk1 changed state do
	(
		if chk1.state == true
			then
			(
				chk2.checked = false
				stopTool toolTwo; startTool toolOne
			)
			else stopTool toolOne
	)
	
	on chk2 changed state do
	(
		if chk2.state == true
			then
			(
				chk1.checked = false
				stopTool toolOne; startTool toolTwo
			)
			else stopTool toolTwo
	)
)
createDialog RO_Tools
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

user can stop a mouse tool by clicking rightclick, pressing ESC, and changing toolmode. You have check all these possibilities to put the state of your checkboxs (checkbuttons, radiobuttons, whatever…) to the order.

by the way, the radiobuttons is most correct UI solution in case what you are doing.

You’re absolutely right about the radiobuttons being more appropriate to what I’m doing. It will take a little fiddling to get them working with the rest of the user interface, but I think I have an idea for that.

I’ve been working on some other functionality in my script and haven’t had a chance to try the toolmode method you pointed out.

As you mention the other ways to shut off a mouse tool… is it possible to write a command into a script that is the equivalent of a right click or pressing the esc key?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i don’t understand the question. you can #stop the tool at any time from inside. you can use freemove event for it for example. from outside you can set the state of some global variable and check this state inside the tool.
also as i said you can stop the tool by changing of toolmode from #create to anything else.

What I meant was, is there a Maxscript command that Max will read as if the user is pressing a particular key or mouse button?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

you can send a message to some window, and the window will read it as a key press or mouse click.

here is a sample how to “click” left mouse button:
http://forums.cgsociety.org/showpost.php?p=6164954&postcount=6

Cool, thanks again!

Okay… finally tried out the toolmode.commandmode method… still no dice. Of the three buttons on this rollout, only the third seems to work.

And looking again at the windows message option… how do I figure out right click, to selected viewport?

try (destroyDialog RO_Tools) catch()
 
 tool toolOne
 (
 	on start do format "starting tool 1
"
 	on stop do format "stopping tool 1
"
 )
 
 tool toolTwo
 (
 	on start do	format "starting tool 2
"
 	on stop do format "stopping tool 2
"
 )
 
 rollout RO_Tools "Mouse Tools"
 (
 	button btn1 "Tool 1"
 	button btn2 "Tool 2"
 	button btn_Quit "Quit"
 	
 	on btn1 pressed do
 	(
 		format "

pressed button 1
"
 		toolMode.commandMode = #SELECT
 		startTool toolOne
 	)
 	
 	on btn2 pressed do
 	(
 		format "

pressed button 2
"
 		toolMode.commandMode = #SELECT
 		startTool toolTwo
 	)
 	
 	on btn_Quit pressed do toolMode.commandMode = #SELECT
 )
 createDialog RO_Tools

I’m just gonna bump this, hoping someone can confirm whether this is a bug, or if I am still doing something wrong…

Denis? Anyone? I still haven’t been able to figure out a satisfactory reason why this doesn’t work, or a way to fix it.

I’ve been working on a different project but hope to get back to this one soon. Unfortunately, I still can’t see what the source of the problem is.

Page 1 / 2