event

class guerilla.event

Bases: object

The event package handles events generated by Guerilla so plugins can interact when such events are triggered.

static register(event, handler)

Associate an event with a handler function

This function lets you associate an event to a function to be called when this event occurs.

Note that handlers are called in an unpredicted order. The event handlers are called always with the signaled event as first argument, and the rest of the arguments given to event.signal. Guerilla signals the following predefined events: Application events:

  • appready (event): called when application is ready and running (note that the initial document might not exist at that point, especially when running the Maya to Guerilla plugin)
  • appclose (event): called before the application closes

Document events:

  • newdocument (event, Document): called after a new document is created
  • loaddocument (event, Document): called after a document is loaded
  • savedocument (event, Document): called before a document is saved
  • closedocument (event, Document): called before a document is closed

Plugin events:

  • exportedproject (event): called when the export plugin finished generating the main project document (which is to be written as a .gproject file)
  • exportedhostproject (event): called when the export plugin finished generating the host project document (which is to be written as a .ghostproject file)

Reference events:

  • refloaded (event, refnode): called after a reference is loaded and before referenced nodes are merged into the scene. refnode is

the loaded reference node, and children of refnode are the nodes contained in that reference. These nodes are not yet part of the Document, and have not yet been prefixed with the reference name. Additionnaly, some referenced nodes may be discarded once merged in the Document. * refmerged (event, refnode, nodes): called after a reference is loaded and after referenced nodes are merged into the scene. refnode is the loaded reference node, nodes is the list of merged nodes in Document.

Render events:

  • prerender (event): called before a render action is performed
  • postrender (event): called after a render action is performed. Note: the event is called right after to render commands are sent to the renderer, not after the render finished.
  • pushrender (event, Render): called after a render is pushed.
  • colorpickerdown (event): called when the color picker is pushed
  • colorpickerdrag (event): called when the color picker is dragged
  • colorpickerup (event): called when the color picker is released

Due to implementation limits, there cannot be more than one handler for an event per source file. –>

param event:The event name to register
type event:str
param handler:The event handler to register
type handler:function
static signal(event, *args)

Trigger an event, and execute registered handlers.

This function allows you to execute event handlers for a particular event. It is possible to register and signal any event,

even not predefined ones. LUA{– Somewhere in init... event.register (“mycustomevent”, function (event, a, b)

print (tostring (event)..” triggered with parameters:”, a, b)

end)

– Later in code local param2 = 12 – trigger the event handler defined above with the arguments “mycustomevent”, “param1” and 12. event.signal (“mycustomevent”, “param1”, param2)}

param event:The event to be triggered
type event:str
param *args:The parameters to be sent to the event handler
type *args:any