mojo.events

publishEvent(key, **attr)

Publish and event with additional info to the active tool and to all the observers.

postEvent(key, **attr)

Post and event with additional info to all the observers. This will not be posted to the active tool.

installTool(event, updateGlyphWindow=True)

Install a tool object.

uninstallTool(event, updateGlyphWindow=True)

Uninstall a tool object.

addObserver(observer, method, event)

Add an observer object for an event with a callback method.

from mojo.events import addObserver

class MyObserver(object):

    def __init__(self):
        addObserver(self, 'myCallback', 'drawBackground')

    def myCallback(self, info):
        # draw here
        pass

removeObserver(observer, event)

Remove and observer object.

getToolOrder()

Return the tool order.

setToolOrder(newOrder, updateGlyphWindow=True)

Set a tool order, the newOrder must have to same tools. Only the order can change.

clearObservers()

Clear all observers

This should never be called cause it will invalidate all the existing observers. It recommended that observer removes it self when it’s done observing an event.

setActiveEventTool(name)

Set the active tool by tool name.

setActiveEventToolByIndex(index, window=None)

Set the active tool by index.

getActiveEventTool()

Returns the active tool.

extractNSEvent(nsEvent)

Return a dictionary with data extracted from the NSEvent object with the following keys.

keyDown
The pressed character
keyDownWithoutModifiers
The pressed characters with modifiers
up
A boolean if the up arrow key is pressed.
down
A boolean if the down arrow key is pressed.
left
A boolean if the left arrow key is pressed.
right
A boolean if the right arrow key is pressed.
shiftDown
A boolean if the shift modifier key is pressed.
capLockDown
A boolean if the capLock modifier key is pressed.
optionDown
A boolean if the option modifier key is pressed.
controlDown
A boolean if the control modifier key is pressed.
commandDown
A boolean if the command modifier key is pressed.

class BaseEventObserver()

A simple EventObserer that can help receiving events and silently catch TypeErrors.

class BaseEventTool()

The base event tool contains all the possible callbacks and will do nothing.

class EditingTool()

The base event tool contains all the possible callbacks and will do nothing.

class MeasurementTool()

The base event tool contains all the possible callbacks and will do nothing.

class SliceTool()

Tool the slice a glyph.

class BezierDrawingTool()

The base event tool contains all the possible callbacks and will do nothing.

Last edited on 13/11/2018