Observer callback format

  • The sample code for observers shows the callback method that looks like this:

    myObserver(self, glyph, info)
    • The callback function needs to have exactly 3 arguments always?
    • The second argument is always an RGlyph?
    • The third argument is always a … what?

    Fiddling around I got the following traceback:

    Traceback (most recent call last):
      File "lib/eventTools/eventManager.pyc", line 76, in postEventObserver_glyph_info_

    Just for my general information as I learn Robofont scripting, can I go look at that source code?

    I'm just trying to figure out how to answer more of my own questions.

  • Why is info a dict instead of an instance of a reall class defined in

    I ask about source code because __doc__ seems to be empty for all the mojo.* modules and classes, and the API documentation is missing a lot. I'm looking for a way to supplement my understanding of the API without asking you a hundred questions.

  • admin

    if you add an observer the callback always receive the current glyph and some additional info related to the event you subscribed to:
    the info object is a dictionary and the content changes from event to event.
    like mouseDown will have:

    "clickCount" : amount of clicks in the glyph view,
    "event" : the nsEvent object,
    "offset" : a offset point used by the glyph view,
    "view" : the glyph view

    (this will change in the next version where a callback only receives a single info dict argument. RF will warn you if you are using the old method)

    euh, no you can not look into the source code