UNSOLVED Are programmed undos able to work across layers?
ryan last edited by gferreira
I'm noticing undos don't seem to work across layers. When I execute the following script and try to
cmd+zon the foreground, it undoes what was done before the script was run.
cmd+zin background layer does not have an undo history. Previous state of background seems to be wiped.
g = CurrentGlyph() with g.undo('Put current glyph in background'): fore = g.getLayer('foreground') back = g.getLayer('background') back.clear() back.appendGlyph(fore) back.width = fore.width back.update() g.update()
g = CurrentGlyph() fore = g.getLayer('foreground') back = g.getLayer('background') with back.undo('Put current glyph in background'): back.clear() back.appendGlyph(fore) back.width = fore.width back.update() g.update()
this is the expected behavior of undo: it is glyph based, and each layer is a separate glyph. the first example doesn’t work because you’re only recording changes to the default layer:
CurrentGlyph()is equivalent to
hopes this makes sense…
glyph.update()is deprecated in RF3, use
ryan last edited by
Hi @gferreira Thanks for the explanation. This certainly makes sense structurally. I'm now wondering if something like this could be made possible in extensions, in cases where the user might expect to be able to undo a whole, somewhat complex action that moves across layers.
Thanks for letting me know about the method deprecation!
For maximum flexibility each glyph has his own undo manager. You dont want to use a single undo manager for everything. I understand in this case a single cmd-Z should perform actions in multiple glyphs.
A while ago Ive made dirty hack... let me see if I can clean it up.