Import from plugs.event_filters and plugs.tick_filters
Filters are decorators that filter out events that shouldn't be processed by a callback function. They provide a simple way to ensure type safety, and add repetitive functionality.
Event filters should be used to decorate registered event callbacks, and tick filters should be used to decorate the tick function of your plugin class.
A number of callback parameters are provided to customize the filter's behavior.
-
method: Whether the function we're decorating is a member function. Defaults toTrue, and should be unset if the callback isn't a member function of your plugin class. -
enforce: Whether to raise an exception if the event is filtered. This could be useful for detecting incorrect behavior in the script. Defaults toFalse. -
filtered_return
Filter out button events if the button is being lifted. Only usable for events.
Filter out events when the index is not a plugin
Filter out events when the index is not a generator plugin
Filter out events when the index is not an effect plugin
Filter out events when the index is not a window
Filter out events when the index is None
To decorate an event callback so that it is guaranteed to be a generator plugin
@event_filters.toGeneratorIndex()
def callback(
self,
control: ControlShadowEvent,
index: GeneratorIndex,
*args: Any
) -> bool:
print("Received callback")
return TrueTo decorate an event callback that isn't bound to a class.
@event_filters.toGeneratorIndex(method=False)
def callback(
control: ControlShadowEvent,
index: GeneratorIndex,
*args: Any
) -> bool:
print("Received callback")
return TrueTo decorate the tick method of a plugin class.
@tick_filters.toGeneratorIndex()
def tick(self, index: GeneratorIndex):
print("Ticking a generator")