Recreate native Glyph inspector panel sidebearing EditText input



  • I'd like to make a sidebearing input essentially like the native RF Glyph inspector panel’s sidebearing input.

    Goals:

    • accepts integers and letters
    • arrow keys + shift + cmd change integers
    • continuous True with arrows + numbers, but False with letter input.

    Normal EditText doesn’t offer the benefits of the arrow key interaction by default. I've tried NumberEditText but it won't allow letters nor will my continuous argument work.

    Thanks!


  • admin

    hello @ryan,

    the Inspector uses GlyphMetricsEditText, which currently lives in lib.UI:

    from lib.UI.glyphMetricsEditText import GlyphMetricsEditText
    

    give it a try… cheers!


  • admin

    import vanilla
    
    from lib.UI.glyphMetricsEditText import GlyphMetricsEditText
    from lib.tools.glyphMetricsMath import glyphMetricsMath
    
    def callback(sender):
        # provide a glyph object, an attribute of that glyph and a text
        value = glyphMetricsMath(CurrentGlyph(), "width", sender.get())
        print(value)
        
    
    w = vanilla.Window((150, 40))
    w.edit = GlyphMetricsEditText((10, 10, -10, 22), callback=callback, continuous=False)
    w.open()
    

    Screen Shot 2019-12-17 at 11.16.21.png



  • @gferreira @frederik

    Thanks!! I should have asked much sooner for Sidebear, haha.



  • Regarding the RF inspector, I think it would be handy if mutltiple glyphs were selected, and user enters a side-bearing value, then it would affect all the selected glyphs. ( ͡° ͜ʖ ͡°)


  • admin

    That is True! for now the inspector is made for inspecting single glyphs. An extension can add a inspector pan with this behaviour!