Removing "Add to Favourites" from context menu
#1
Hi,
Is there a way of removing the "Add to Favourites" from the default context menu?
Is there a way of intercepting it or maybe adding an <onclick> to run a script with the favourite as argument?
I would also like to add extra information to a favorite.

Thank you in advance
Reply
#2
+1

I could not find any notifications or hooks for when the user select add to favorite from context menu. Does something exists to allow plugin to do something following the action?
Reply
#3
Sure. When you add the directoryitems you can call it this way:

Quote:liz=xbmcgui.ListItem('You directory label', iconImage="DefaultFolder.png", thumbnailImage='your icon')
contextMenuItems = []
contextMenuItems.append('This is a context menu entry', 'XBMC.RunPlugin(Your_path_goes_here)')
liz.addContextMenuItems(contextMenuItems, replaceItems=True)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url='your_playable_url',listitem=liz,isFolder=False)

Basically the code above creates a listitem with your label, icon and playable url and adds it as a directory item to kodi's gui. It also appends a new entry called "This is a context menu entry" that will run the builtin function you assign on the right (in the case Xbmc.RunPlugin). When you add this contextmenuitem to the listitem (liz) and define replaceItems as True any item that is default by kodi will be removed from the context menu. So if you want to change the way the add to favourites work, your best bet is to follow this route. Basically say to kodi that you want to replace all the default context menu items and create another with the same label that would run the bultin function you desire.

Good luck for your plugin

cheers
Reply
#4
@enen92

Thank you for this! Very much appreciated. I will explore this route.
Reply
#5
Thank you enen92. I have another question: if I create my own control ControlList in a window and add items to it can I have a context menu in it? like:

Code:
...
        controlList = xbmcgui.ControlList(200,200,500,500,font='font14',textColor='yellow',selectedColor='green')
        self.addControl(controlList)
        liz = xbmcgui.ListItem("test item", iconImage="DefaultFolder.png", thumbnailImage='DefaultFolder.png')
        
        contextMenuItems = []
        contextMenuItems.append(('Context test', 'RunScript(special://home/scripts/foo/default.py, bar)',))
        contextMenuItems.append(('Context test2', 'RunScript(special://home/scripts/foo/default.py, bar)',))
        
        liz.addContextMenuItems(contextMenuItems, replaceItems=True)
        controlList.addItem(liz)
        ...

The above code does not show any context menu :/
Reply
#6
If anyone has the same problem I ended up puting the control in xml and catching the action id 117 and doing a xbmcgui.Dialog().select in place of the context menu:

Code:
...
    def onAction(self, action):
        if action.getId() == 117: #context menu
            controlList = self.getControl(20)
            selecteditem = controlList.getSelectedItem()
            ret = xbmcgui.Dialog().select(selecteditem.getLabel(...), ...

help was from this post: http://forum.kodi.tv/showthread.php?tid=...pid1513525 Big Grin
Reply

Logout Mark Read Team Forum Stats Members Help
Removing "Add to Favourites" from context menu0