SOLVED list all undos



  • Hi, please, is there a possibility of getting all current font's undos listed? Or is there a way to how to add observer to afont's undo? So I can use it in an extension that knows about every recorded undo? Thanks!



  • @gferreira thanks a lot! I will look into it :)



  • hello @jansindl3r,

    the latest beta includes the new addedUndoItem observer, which returns a dict of the glyph data before each change.

    here’s an example:

    from mojo.events import addObserver
    
    class MyUndoItemObserver:
    
        def __init__(self):
            addObserver(self, "addedUndoItemCallback", "addedUndoItem")
    
        def addedUndoItemCallback(self, notification):
            glyph = notification['glyph']
            glyphData = notification['data']
            print(f'{glyph.name} changed' )
            print(glyphData)
            print()
    
    MyUndoItemObserver()
    

    please give it a try… thanks!


  • admin

    From a nsUndoManager there is no way to get a list of undo's and redo's. There is no api for it...

    The addedUndoItem will help to make such a list of changes..



  • Isn't there some way to crack there from RoboFont 3.3?

    I tried something like this. It seems that it is not linked, because it tells that it has no undo on the stack. I am doing something wrong, or is there just no way how to get to that stack? Thanks

    import AppKit
    g = CurrentGlyph()
    manager = AppKit.NSApp().currentDocument().getUndoManagerForGlyph_(g)
    print(manager._undoStack().count())
    


  • Hi!
    Thanks a lot! Looking forward :)


  • admin

    There is no support from the macOS NSUndoManager to have access to a stack of undo items.

    Ive added an addedUndoItem notification where an extension could collect all the undo items and step over or save every version... lots of possibilities!!!



  • hello @jansindl3r,

    a list of undos by title is not available, but an observer for undo actions is coming soon … stay tuned!


Log in to reply