observer callback format

RoboFont Forums Help / General observer callback format

This topic contains 2 replies, has 2 voices, and was last updated by  butterick 8 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3647

    butterick
    Participant

    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.

    #3649

    frederik
    Keymaster

    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

    #3650

    butterick
    Participant

    Why is “info” a dict instead of an instance of a reall class defined in mojo.events?

    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.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.