Add Option to Menu

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

MyVikes
Posts: 91
Joined: Sun Jul 02, 2017 1:20 am

Add Option to Menu

Post 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.
drakinite
Posts: 965
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: Add Option to Menu

Post 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)
});
Image
Student electrical-computer engineer, web programmer, part-time MediaMonkey developer, full-time MediaMonkey enthusiast
I uploaded many addons to MM's addon page, but not all of those were created by me. "By drakinite, Submitted by drakinite" means I made it on my own time. "By Ventis Media, Inc., Submitted by drakinite" means it may have been made by me or another MediaMonkey developer, so instead of crediting/thanking me, please thank the team. You can still ask me for support on any of our addons.
MyVikes
Posts: 91
Joined: Sun Jul 02, 2017 1:20 am

Re: Add Option to Menu

Post 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!
drakinite
Posts: 965
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: Add Option to Menu

Post 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?
Image
Student electrical-computer engineer, web programmer, part-time MediaMonkey developer, full-time MediaMonkey enthusiast
I uploaded many addons to MM's addon page, but not all of those were created by me. "By drakinite, Submitted by drakinite" means I made it on my own time. "By Ventis Media, Inc., Submitted by drakinite" means it may have been made by me or another MediaMonkey developer, so instead of crediting/thanking me, please thank the team. You can still ask me for support on any of our addons.
Ludek
Posts: 4959
Joined: Fri Mar 09, 2007 9:00 am

Re: Add Option to Menu

Post by Ludek »

Also be sure that the trackListView_add.js is under /controls/ subfolder.
i.e. /scripts/<your addon name>/controls/trackListView_add.js
MyVikes
Posts: 91
Joined: Sun Jul 02, 2017 1:20 am

Re: Add Option to Menu

Post 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!
Post Reply