Disable/Enable menuItems #40
Comments
Fixed with 110e9d8 |
PluginHost.globalMenuID is currently undocumented (and there was a bug, fixed in master), but with the next release it should work. from ts3plugin import ts3plugin, PluginHost
import ts3defines, ts3lib
class menutest(ts3plugin):
name = "menutest"
requestAutoload = False
version = "1.0.0"
apiVersion = 21
author = "Thomas \"PLuS\" Pathmann"
description = "Showcase to enable/disable pluginmenus"
offersConfigure = False
commandKeyword = "menu"
infoTitle = None
menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Menutest", "icon.png")]
hotkeys = []
def __init__(self):
self.dlg = None
def stop(self):
pass
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
if menuItemID == 0:
print("menu clicked")
def enableMenu(self, on):
globid = PluginHost.globalMenuID(self, 0)
if globid:
ts3lib.setPluginMenuEnabled(globid, on)
def processCommand(self, schid, command):
tokens = command.split(' ')
if len(tokens) == 0:
return False
if tokens[0] == "enable":
self.enableMenu(True)
return True
elif tokens[0] == "disable":
self.enableMenu(False)
return True
return False |
Does your code still apply to 229c137 ? |
…ems are setup (again), eg after reload, to let them possibly disable them again
Yes.
No, that's not the meaning of "global" in that function. Every plugin uses "local identifier" to reference only the menuItems, this specific plugin uses. The PythonHost translates them to "global identifiers" and sends them to the TS3 client. With this method, it is not necessary, that each plugin uses unique identifiers.
The masterplan is, to update the documentation. |
https://github.com/Kleberstoff/TS-Plugins-API-21/blob/master/anti-move/src/plugin.c#L161
I wish this would exist in pyTSon
The text was updated successfully, but these errors were encountered: