Is it possible to create "toggle" like context menu addon?
#1
I have a context menu addon to add current movie list item to "watchlist", where watchlist is a predefined tag, so the addon is adding or removing the tag.
The addons internal logic implements the toggle functionality examining the condition if the current list item already have the tag, then removes the tag, otherwise adds the tag.

The context menu item title is : "Add to / Remove from watchlist"

I would like to improve the user experience having two different titles, and display the correct based on the current item state: "Add to watchlist" or "Remove from watchlist"

I do know that in addon.xml, there is a <visible> element, which drives the conditional visibility of a context menu item, so I thought I define both two context menu items, and declare the visibility of them based on condition of the current item have the watchlist tag or not. However such a custom logic seems to not available in the <visible> element, or I missed something.

Same time I see, that the built in context menu "Mark as watched"  vs  "Mark as unwatched" somehow implements it.

Is it possible similar user experience for my "Add to / Remove from watchlist" context addon?
Reply
#2
you can simpy use list_item.addContextMenuItems (https://codedocs.xyz/AlwinEsch/kodi/grou...e23a1a78c2)
so for each listitems of the directory that you will make:

python:
context_menus = []
if is_in_watchlist:
  context_menus.append(('Remove from watchlist', 'script action to do'))
else:
  context_menus.append(('Add to watchlist', 'script action to do'))
list_item.addContextMenuItems(context_menus)
Dev-Maintainer of InputStream Adaptive add-on, Netflix add-on ▫ Skills Python, C#, VB.NET and a bit of C++
Reply

Logout Mark Read Team Forum Stats Members Help
Is it possible to create "toggle" like context menu addon?0