Modify glyph copy/paste behavior for custom contexts?
-
Hi Frederik,
I love how copy-pasting a glyph renders it in different ways in different contexts – like how it prints out the glif data if you try to copy-paste to a text field.
I’m wondering about modifying this behavior in special cases. Specifically, looking at improvements for word-o-mat I was wondering if it might be useful for the user to be able to copy-paste glyphs into the input text fields. (I’m not sure it’s actually a good idea, but some people may try to do that.) But then of course I would want the glyph name to be pasted, not the XML data (which is what currently happens, as the text field is identified as a text-only context, I guess).
So I’m wondering whether it is (a) possible and (b) actually desirable/a good idea/good form to make the glyph paste itself as a name instead of the xml data in such a case?
Thanks for your thoughts,
Nina
-
Thanks Frederik. That’s a very useful start. I see it does not inherit/use the text attribute of the Vanilla EditText, which I need, but I guess I’ll look into making a subclass of my own ... maybe for the version after next ;)
-
He Nina
Space Center already doest that, in all three input boxes. You could use that for Word-O-Mat... so it has support for pasting glif xml
from lib.UI.spaceCenter.glyphSequenceEditText import GlyphSequenceEditText from vanilla import * class Test: def __init__(self): self.w = Window((200, 100)) # the only tricky thing is that it is optimized for the lowerlevel defcon font object... self.w.input = GlyphSequenceEditText((10, 10, -10, 22), CurrentFont().naked(), callback=self.inputChangedCallback) self.w.open() def inputChangedCallback(self, sender): print sender.get() Test()
FYI:
RoboFont writes different representations to the pasteboard, any thing that is responding to a paste action can read their preferred representation.
it is possible to add you're own representations if you subscribe to the paste notification, just a add or rewrite whatever you like :)