Extended Tags/Blacklist addons

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

Moderators: jiri, drakinite, Addon Administrators

Platonius
Posts: 22
Joined: Mon May 25, 2020 9:37 am

Extended Tags/Blacklist addons

Post by Platonius »

Hi all,

Trying to get my head around the way JS/MM5 works with overrides and extendability, but I'm running into some problems.

I want to add an option to the sendTo menu. Which means I need to add an entry in actions.js to window.actions, the sendto entry and the submenu function.

How would I be able to do this? Haven't found a proper way to create an entry in actions_add.js that would use the sendTo menu. Tools and editTags have their own defined _menuItems entry, but that doesn't seem to exist for the sendTo menu.

Anybody can point me in the right direction?
drakinite
Posts: 567
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: Extended Tags/Blacklist addons

Post by drakinite »

The "Send To" is controlled by actions.sendTo, and the submenu is controlled by the function actions.sendTo.submenu.

You can override it with the Override function (documented here: https://www.mediamonkey.com/wiki/Import ... )#Override)

Since the original submenu returns a Promise, you can make your code simpler by using an async function. First you get the original result (which is an array of actions) by taking the result of the $super parameter, then just add to the array with your custom action, and return the modified array. You can choose whatever grouporder and order you want in order to decide where in the submenu your action appears.

Code: Select all

actions.sendTo.override({
    submenu: async function($super, params) {
        var result = await $super(params);
        result.push({
            icon: 'add',
            title: 'My Custom Action',
            execute: function () {
                uitools.toastMessage.show('Hello world!', {disableUndo: true});
            },
            order: 50,
            grouporder: 20,
        });
        return result;
    }
});
Image
Student electrical-computer engineer, web programmer, part-time MediaMonkey developer, full-time MediaMonkey enthusiast
Platonius
Posts: 22
Joined: Mon May 25, 2020 9:37 am

Re: Extended Tags/Blacklist addons

Post by Platonius »

Thanks! On to the next problem ;)
Post Reply