help claims that guideline.selected exists but does not
I know that this is probably not a way how to get active guideline, but the help says it is.
g = CurrentGlyph() for guideline in g.guidelines: help(guideline) #print(guideline.selected) break
| Data descriptors inherited from fontParts.base.base.SelectionMixin: | | selected | The object's selection state. | | >>> obj.selected | False | >>> obj.selected = True
guidelines currently don’t implement the
selectedattribute in RF.
not sure if there’s a reason behind it… seems like it could be useful? @frederik
in RF a guide is only selected during a drag... so in all other cases they are not selected!
how do you get the activated guideline, then? If I right click and want to have contextual action for this specific guideline? right clicked == dragged?
you can add a item in the guideline contextual menu by subscribing to the notification:
guideAdditionContextualMenuItemsand append a tuple of
(menu titles, callback)to
additionContextualMenuItemskey in the notification object.
Maybe it is not clear to me, but should be the active guideline in the sender argument of function
testje? I want to right click the guideline and flip it horizontally or vertically.
from mojo.events import addObserver, clearObservers # clearObservers() class Test(object): def __init__(self): addObserver(self, "guideAdditionContextualMenuItems", "guideAdditionContextualMenuItems") def guideAdditionContextualMenuItems(self, notification): myMenuItems = [ ("testje", self.testje), ] notification["additionContextualMenuItems"].extend(myMenuItems) def testje(self, sender): print(dir(sender)) Test()
the current guideline is only available from an interactive tool.
here’s an example: (shift-click guide to flip direction)
from mojo.events import EditingTool, installTool class FlipGuideTool(EditingTool): def getToolbarTip(self): return "flip guide" def mouseDown(self, point, clickCount): g = CurrentGlyph() guides = CurrentGuidelines() if guides and self.shiftDown: guides.angle += 90 installTool(FlipGuideTool())