Hello, I would like to emulate the behaviour that the hinting plugin uses: Nodes are selectable, but not editable, and this is reflected in the UI. Is there an easy way to achieve this in a reporter plugin? Thanks!
not with a reporter. You need a tool for this.
Sorry, I am not working with a reporter, I have it in a .glyphsTool. How would I do this in a tool?
Overwrite the drawHandle:… method like this:
- (void)drawHandle:(GSPath *)path atIndex:(NSUInteger)idx isSelected:(BOOL)selected atPoint:(NSPoint)layerOrigin simple:(BOOL)simple {
GSNode *node = [path nodeAtIndex:idx];
[self drawKnob:node.position type:node.type selected:selected atPoint:layerOrigin];
}
Thanks. Is this possible in Python?
Just replace : with _ ![]()
Hi again, sorry to come back to this. I still don’t understand. In my SelectTool code, I have:
@obj.python_method
def drawHandle_(self, path, index, isSelected, layerOrigin, simple=False):
print("Hello world")
When I activate my select tool, nothing happens, though. How do I do this correctly? Do you have a sample plugin I can look at with similar code? Thanks!
you need the full method name. In objectiveC it is interlaced with the arguments. There are many : to replace:
def drawHandle_atIndex_isSelected_atPoint_simple_(path, idx, selected, layerOrigin, simple):
I had tried that, but didn’t get it to work.
When I use the @objc.python_method decorator, nothing happens. The print statement has no effect.
When I don’t use the decorator, I get:
objc.BadPrototypeError:
'drawHandle:atIndex:isSelected:atPoint:simple:' expects 5 arguments,
<function MyPlugin.drawHandle_atIndex_isSelected_atPoint_simple_
at 0x156377880> has between 3 and 4 positional arguments
For reference, this is my code:
def drawHandle_atIndex_isSelected_atPoint_simple_(path, index, selected, layerOrigin, simple=False):
print("Hello World")
Ah! I need to have self as the first argument as well. Now it works. Thanks a lot!
Another question: How do I make the nodes unmovable, like in the hinting plugin?
you can try to overwrite:
def moveSelectionWithPoint_withModifier_(self, offset: NSPoint, modifierFlag: int):
and only move whatever you need.
Thank you very much!