Handling selection in a Custom Tool

RoboFont Forums Help / General Handling selection in a Custom Tool

This topic contains 2 replies, has 2 voices, and was last updated by  Jens K. 7 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5488

    Jens K.
    Participant

    Is there a standard way to handle the selection/unselection of points in a custom tool?

    I mean something like the EditingTool behaves. When I subclass my custom tool from the EditingTool, the selection behaviour is there, but I don’t want the editing/moving of points in my tool.

    If I subclass the BaseEventTool, I know how to find out where clicking/dragging starts and stops, but is there an easy way to find out the affected points to manage the selection myself? Something like CurrentGlyph.getPointsInsideBox((x0, y0), (x1, y1)) perhaps?

    #5489

    frederik
    Keymaster

    there is no standard way to set the point selection

    you can use fontTools pointInRect

    from fontTools.misc.arrayTools import pointInRect
    
    for contour in CurrentGlyph():
        for point in contour.points:
            print pointInRect((point.x, point.y), (minx, miny, maxx, maxy))
    

    take a look at the PolygonSelectionTool https://github.com/typemytype/RoboFontExamples/blob/master/tools/polygonSelectionTool.py

    good luck!

    #5491

    Jens K.
    Participant

    Great, thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.