Does any have a macro that toggles all the edit tools. As I am using Stream Deck I would want it to toggle between TRIM-SELECT-GRAB each time I press a button. I don't see any Macros that do this. Thanks in advance for anyone who can help.
Linked from:
- samuel henriques @samuel_henriques
Hello @Mark_Mangini,
Try this, let me know how it goes.
It's possible to remove the Smart Tool if you wantsf.ui.proTools.appActivateMainWindow(); const btn = sf.ui.proTools.mainWindow.groups.allItems[2].buttons const trimBtn = btn.allItems[2].invalidate().value.value === "Selected" const selectorBtn = btn.allItems[3].invalidate().value.value === "Selected" const grabberBtn = btn.allItems[4].invalidate().value.value === "Selected" let selectTool switch (true) { case trimBtn && selectorBtn && grabberBtn: selectTool = "Trim" break; case trimBtn: selectTool = "Selector" break; case selectorBtn: selectTool = "Grabber" break; case grabberBtn: selectTool = "Smart" break; } sf.ui.proTools.toolsSelect({ tool: selectTool }) // Red lined but works
samuel henriques @samuel_henriques
UPDATE: changed to Switch Statement, it seams to make more sense.
Christian Scheuer @chrscheuer2021-04-19 01:33:09.094Z
Hi Samuel,
Your updated switch statement unfortunately doesn't make much sense, since you're switching on a constant, not a variable. AFAIK you can't make it work this way.
You were also using an indexed group to get to the items (the
groups.allItems[2]
) - this is not very stable, since it is dependent on groups potentially being rearranged.In this code, I'm using SoundFlow's built in syntax for the cursor tool cluster to get directly to the correct buttons :)
const { trimTool, selectorTool, grabberTool } = sf.ui.proTools.mainWindow.cursorToolCluster; const isTrimTool = trimTool.value.invalidate().value === 'Selected'; const isSelectorTool = selectorTool.value.invalidate().value === 'Selected'; const isGrabberTool = grabberTool.value.invalidate().value === 'Selected'; /**@type {'Trim' | 'Selector' | 'Grabber' | 'Smart'} */ let newTool = 'Trim'; if (isTrimTool && isSelectorTool && isTrimTool) newTool = 'Trim'; else if (isTrimTool) newTool = 'Selector'; else if (isSelectorTool) newTool = 'Grabber'; else if (isGrabberTool) newTool = 'Smart'; sf.ui.proTools.toolsSelect({ tool: newTool });
samuel henriques @samuel_henriques
Hey @chrscheuer thank you for jumping in,
I did wander if
groups.allItems[2]
could have problems in different systems.
This makes it way betterconst { trimTool, selectorTool, grabberTool } = sf.ui.proTools.mainWindow.cursorToolCluster;
Didn't know you could choose the propery like this, awesome
And now we have access to the smartToo valuel, we can clean up that &&:
const { trimTool, selectorTool, grabberTool, smartTool } = sf.ui.proTools.mainWindow.cursorToolCluster; const isTrimTool = trimTool.value.invalidate().value === 'Selected'; const isSelectorTool = selectorTool.value.invalidate().value === 'Selected'; const isGrabberTool = grabberTool.value.invalidate().value === 'Selected'; const isSmartTool = smartTool.value.invalidate().value === 'Selected'; /**@type {'Trim' | 'Selector' | 'Grabber' | 'Smart'} */ let newTool = 'Trim'; if (isSmartTool) newTool = 'Trim'; else if (isTrimTool) newTool = 'Selector'; else if (isSelectorTool) newTool = 'Grabber'; else if (isGrabberTool) newTool = 'Smart'; sf.ui.proTools.toolsSelect({ tool: newTool });
Just noticed that this
sf.ui.proTools.toolsSelect({ tool: undefined });
will select trimTool, that's why I didn't notice I needed a default value, so I'm guessing you usedlet newTool = 'Trim';
instead oflet newTool
to have a default ?About the switch i'll make a new thread so it doesn't clutter this one.
@Mark_Mangini, I'm sorry, I'm learning as I go. Although the two codes might behave the same now, you should change to Christian's, technically his is more error proof.
Thank you so much Christian.
- MMark Mangini @Mark_Mangini
So which code should I copy?
samuel henriques @samuel_henriques
this is the best one, I made a slight change to it but @Christian might have something to add.
Christian Scheuer @chrscheuer2021-04-19 15:18:01.579Z
Confirming: This latest version from Samuel is the best one :)
- MMark Mangini @Mark_Mangini
Yup, that works really well, too. Thank you both.
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
Thank you Samuel. That works great!!