Page 1 of 1
Add Option to Menu
Posted: Sun Oct 03, 2021 2:27 pm
by MyVikes
I've written an action and assigned a hot key sequence to it and all works great. Now I'm trying to add a menu option when right clicking on a track to to execute the action but I'm stumped.
As customizable as MM5 seems to be it seems this should be doable and I've reviewed and even installed a couple of the sample scripts such as the one for the options panel and the properties tab hoping they might offer some direction but no luck.
If anyone could offer some help or concrete examples it would be much appreciated.
Re: Add Option to Menu
Posted: Sun Oct 03, 2021 4:29 pm
by drakinite
You can find all you need in trackListView.js.
When you right click on a track, the function
menus.createTracklistMenu is called. It uses the list of items inside
menus.tracklistMenuItems to create the tracklist.
To add an item to the list, do:
Code: Select all
menus.tracklistMenuItems.push({
action: (your action),
order: (the order in which your menu item should appear),
grouporder: (whichever group you want it to appear in)
});
Re: Add Option to Menu
Posted: Sun Oct 03, 2021 7:18 pm
by MyVikes
Thanks for the direction but
i run this in the DevTools console:
Code: Select all
window.menus.tracklistMenuItems.push({
action: actions.setAddedOn,
order: 1
});
and i then do a:
Code: Select all
console.log(window.menus.tracklistMenuItems);
and i see
...
26: {action: {…}, order: 30, grouporder: 60}
27:
action: {title: "Set Added On to today's date", hotkeyAble: true, disabled: false, visible: true, execute: ƒ, …}
order: 1
__proto__: Object
length: 28
__proto__: Array(0)
AND now I see it when right clicking on a track BUT of course it's
not persistent. So i added this to my custom action code but it gives an error when installing. So then i created a new Addon with a name of tracklistview_add.js and install it but it doesn't show up in the menu.
I'll keep plugging away though...thx Drakinite.
Thanks Again!
Re: Add Option to Menu
Posted: Mon Oct 04, 2021 12:58 pm
by drakinite
Hmm... I'm not sure if the _add file framework is case sensitive. When I tested it with a prototype addon a little while ago, doing window.menus.tracklistMenuItems.push worked inside trackListView_add.js. Try fixing the capitalization of your script and see if that fixes it?
Re: Add Option to Menu
Posted: Mon Oct 04, 2021 3:07 pm
by Ludek
Also be sure that the trackListView_add.js is under /controls/ subfolder.
i.e. /scripts/<your addon name>/controls/trackListView_add.js
Re: Add Option to Menu
Posted: Mon Oct 04, 2021 5:33 pm
by MyVikes
That was it Ludek....i recalled seeing that once you mentioned it but this being the first...oh well, i won't forget that one again.
Thx so much!