RoboFont › Forums › Help / General › Undo for multiple glyphs/list?
Tagged: undo
This topic contains 7 replies, has 2 voices, and was last updated by franz 8 years, 7 months ago.
-
AuthorPosts
-
March 16, 2012 at 12:40 #3823
Hi,
Currently working on my first tiny script/extension, all is working well in term sof functionality, the only thing I can’t seem to get working is the undo:
The user can scope the operation to be applied to either all glyphs of a font or just a selection, which in both cases results in a list of glyphs I then loop through.
Want I’d want is to add the prepareUndo and performUndo to the list object that contains all the glyphs the user has selected.
So my list is either
glyphNames = font.keys()
OR
glyphNames = font.selectionSo when I call
glyphNames.prepareUndo(“blah”)
#functionality goes here
glyphNames.performUndo()I get this in the output
AttributeError: ‘list’ object has no attribute performUndo()
Is there any way to get an undo working for a list of glyphs?
Or do I need to import a specific module to get the undo working apart from the ones I have (AppKit, vanilla, defcon BaseWindowController)?Any help would be much appreciated, my apologies if that’s a terribly stupid question, I just want to learn and find my way around here, my knowledge of Python is is much less than what you could call limited…
Many thanks,
FranzMarch 16, 2012 at 19:58 #3824He
A list object does not have a
prepareUndo preformUndo
methods.The best way is to tell each glyph while looping over all
glyphNames
toprepareUndo preformUndo
font = CurrentFont() glyphNames = font.selection if not glyphNames: glyphNames = font.keys() for glyphName in glyphNames: glyph = font[glyphName] glyph.prepareUndo("myAction") # action start glyph.move((100, 100)) # action end glyph.performUndo()
You can have multiple undo’s when selecting multiple glyphs in the Font Overview and hit ⌘-Z
Bundling undo states over several glyphs into one undo state isn’t possible cause each glyph has his own undo manager.hope this helps
March 18, 2012 at 09:53 #3825Hi Frederik,
many thanks, works a treat!
I just wasn’t aware the undo manager was bound to the glyph.Franz
March 19, 2012 at 09:36 #3826Hi Frederik,
one more thing: The Undo/Redo seems to be available in the Edit menu only when the Font Collection or the Glyph Editor window has the focus, not when my own window is in front.
Am I still doing something wrong or is this OK/expected behaviour?
Sorry to be a pain, I just want to know if I’m doing ok and learn a bit while at it :-)
Many thanks,
FranzMarch 20, 2012 at 07:59 #3827In any event, I have just pushed my first little RoboFont Extension to github:
March 20, 2012 at 08:08 #3828cool
you could change the vanilla.Window to a vanilla.FloatingWindow
A floating window will not became the first responder to actions send by fe. the menu bar.
succes!
March 20, 2012 at 08:23 #3830Many thanks Frederik, I tried that but felt somewhat awkward (at least to me), not in terms of Undo but in the environment of the other windows. Will reconsider though.
March 20, 2012 at 20:19 #3831Ok, convinced :-)
It’s a floating window now.Just pushed 1.1 to github:
-
AuthorPosts
You must be logged in to reply to this topic.