Way to detect the active tool?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Way to detect the active tool?

Post by lehtiniemi »

Is there a way to detect the active tool?

I'm trying to find a way to detect which part of the layer the user wants to manipulate: bones or the layer translation. Both can coexist and I want to find a way to figure out automatically which one the user wants to animate. I was thinking that if the user has Transform layer -tool active, he/she wants to manipulate layer data. Same with bone tool -> bone data.

If detecting the active tool isn't possible, any other ideas how to determine which one the user is working on currently? Active tool would be the easiest to use as the source.
User avatar
synthsin75
Posts: 9935
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Way to detect the active tool?

Post by synthsin75 »

I can't think of any way to detect current tool, but you may be able to detect last keyframe added.

It would be messy, but you might be able to undo/redo to find which keyframe was added last. I think this would be awfully slow, for each keyframe in each channel, and you might even need to make multiple undos/redos (since undo can effect more than keyframes being added).

The only other way I can think of would require you modding all the AS tools to update a ScriptData variable when used. That would be hard to maintain though.


I don't think I'd want to tackle either option.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: Way to detect the active tool?

Post by lehtiniemi »

Thanks! I guess I'll just split the script into two in that case, until I can find some way (or support for such detection arises in future versions)
JeroenKoffeman
Posts: 32
Joined: Tue Mar 24, 2015 3:04 pm

Re: Way to detect the active tool?

Post by JeroenKoffeman »

In moho 12 it's possible:

ScriptInterface:CurrentTool()

http://mohoscripting.com/index.php?show ... ce&id=1227
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: Way to detect the active tool?

Post by lehtiniemi »

JeroenKoffeman wrote:In moho 12 it's possible:

ScriptInterface:CurrentTool()

http://mohoscripting.com/index.php?show ... ce&id=1227
Oooh WOW! Thanks for the info! :))) this makes tool scripting much smarter and reduces the amount of scripts.
User avatar
synthsin75
Posts: 9935
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Way to detect the active tool?

Post by synthsin75 »

Thanks, Jeroen, I'd never seen that one.
Post Reply