Events
Events will be triggered on different circumstances like, on click, on enabled, on message receive etc. Events can call/trigger actions.
With plugins you can add and call/emit your own events and define when they should be executed as well parse date within these events.
Register an Event
Within the afterInit function, the following code will add an event:
def afterInit(self):
self.registerEvent(NameString, IdentifyerString)Example
self.registerEvent("Example Event Name", "ExampleEventIdentifyer")Two comma separated strings are necessary to register the event properly:
The first string is defining the name how a user would find the event within the menu.
The second one is the name of the event itself and the identifier to call it.

Emit / Call an Event
To call/emit the event, the following code is required:
self.emitEvent(IdentifyerString)Example
self.emitEvent("ExampleEventIdentifyer")Whenever within your code you are calling this function, the event will be emitted/triggered.
Make sure the IdentifyerString is matching from the register
Register an Event with a parameter
self.registerEvent("Name", "Identifyer", scriptTokens=["Value"])The scriptTokens= is a variable of a type List.
Emit / Call an Event with a parameter
self.emitEvent("Identifyer", sp.ValueTree.fromDict({"Value": 123},"root"))Register an Event with parameters
self.registerEvent("Name", "Identifyer", scriptTokens=["Value", "Value2", "Value3"])Emit / Call an Event with parameters
data = sp.ValueTree("root")
data["someData"].value = 123
data["moreData"].value = False
self.emitEvent("Identifyer", data)or from Dict:
someDict = {"someData": 123, "moreData", False}
self.emitEvent("Identifyer", sp.ValueTree.fromDict(someDict),"root")Last updated