PDA

View Full Version : Hide subtool under mouse



inverse catheter
10-23-11, 05:55 PM
hi guys. i'm looking to create a script that will ( as the thread title says ) hide the subtool under mouse ( location ). the idea being that it would use that aspect similar to marcus' AutoSelectSubTool ( essentially echoing a mouse click under the position of the cursor ) and turn off the visibility ( eye ) of that subtool

in loose macro form :

hit the key ( hotkeyed macro ). the current subtool is stored as var0
the subtool you want to hide is ( ' selected ' and ) stored as var1
script switches back to var0 and hides var1

.

if anyone has a script similar. or know of some functionality i'm missing that achieves the same thing i would be hugely grateful for any help

thanks

inverse catheter
10-25-11, 08:54 PM
//define vars
[VarDef, SubToolTitle_0,"null"]
[VarDef, SubToolTitle_1,"null"]
//
//set var0 to current tool
[VarSet,SubToolTitle_0,[IgetTitle, Tool:Current Tool]]
//
//do select. . . ( marcus civis )
[IPress,Preferences:Edit:Auto Select SubTool]
[IKeyPress,1064,[CanvasClick,[MouseHPos],[MouseVPos]]]
[IUnPress,Preferences:Edit:Auto Select SubTool]
//
//and then set var1 to that selection
[VarSet,SubToolTitle_1,[IgetTitle, Tool:Current Tool]]
//
//hide var1
[IModSet,[StrMerge,"Tool:SubTool:",SubToolTitle_1],1]
//
//switch back to var0
[IPress,[StrMerge,"Tool:SubTool:",SubToolTitle_0]]
//
//PIOW !!
]

so. putting that into this loose macro form. it works sometimes, and yet others spits the error :

279153

here i just lifted the IPress from a zb macro and replaced with the variable. if anyone can hint as to where i've messed up then thanks heaps

.

marcus_civis
11-03-11, 01:53 PM
This is quite complex because you need to make sure that the subtool is visible in the subtool list before trying to 'press' it. So you need to find the active subtool in a slightly different way. The code shows one method. This positions the scrollbar so that the subtool at position '0' is tested to see if it is the active subtool. This is only necessary when there are more than 8 subtools, as with 8 or less all subtools are always visible in the list.

This also uses the string compare method to test for the active subtool so it isn't turned off (though this could fail if there were two subtools of the same name).



//store the scrollbar position
[VarSet,tmpScrollPos,[IGetSecondary,Tool:Sub Tool:SubTool ScrollBar]]
//find the selected subtool
[VarSet,totalSubTools,[StrExtract,[IGetTitle,Preferences:Misc:SubTools Count],10,256]]
[If,totalSubTools>8,
[VarSet,i,1]
[VarSet,subToolPath,"Tool:Sub Tool:SubTool 0"]
[Loop,totalSubTools,
[VarSet,scrollPos,(totalSubTools-i)]
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]
[If,[IGetFlags,#subToolPath]>=9,
[VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
[LoopExit]
]
[VarInc,i]
]
,
[VarSet,scrollPos,tmpScrollPos]
[Loop,totalSubTools,
[VarSet,subToolPath,[StrMerge,"Tool:Sub Tool:SubTool ",[Val,n]]]
[If,[IGetFlags,#subToolPath]>=9,
[VarSet,activeSubT,[IGetTitle, Tool:Current Tool]]
[LoopExit]
]
,n]
]

//do select. . . ( marcus civis )
[IPress,Preferences:Edit:Auto Select SubTool]
[IKeyPress,1064,[CanvasClick,[MouseHPos],[MouseVPos]]]
[IUnPress,Preferences:Edit:Auto Select SubTool]
//
//and then set var1 to that selection
[VarSet,hideSubT,[IGetTitle, Tool:Current Tool]]
//hide var1

[If,([StrLength,hideSubT]==[StrLength,activeSubT])&&([StrFind,hideSubT,activeSubT]>-1),
//active subtool - do nothing
,//if it's not the active subtool
[IModSet,[StrMerge,"Tool:SubTool:",hideSubT],1]
]

//switch back to selected subtool
//set the scrollbar so subtool shows
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,scrollPos]
//select subtool
[IPress,#subToolPath]
//reset scrollbar
[ISet,Tool:Sub Tool:SubTool ScrollBar,0,tmpScrollPos]

HTH,

marcus_civis
11-04-11, 01:26 AM
I meant to add that you only need to press and unpress the Preferences:Edit:Auto Select SubTool if you have that option turned off by default (perhaps because you are using my AutoSelect SubTool macro). Otherwise you will be left without the ability to Alt+click a subtool to select it.