I’m trying to make a script that will just place a vertical guideline where the mouse is (and set the correct italic angle of the guideline according to the italic angle). But I cant figure out how to get the x, y of the mouse in this way, whats the correct method?
It has been done before. Please take a peek in the ShowCrosshair plug-in.
Is there some kind of scaling I need to apply because I can’t figure it out, even without an italic angle
mousePosition = Glyphs.currentDocument.windowController().activeEditViewController().graphicView().getActiveLocation_(Glyphs.currentEvent())
I should clarify I want go make an actual guideline. Not just draw a line at the mouse. I want to make a script so I can make a shortcut to make a guideline that’s already italicissd at the mouse position.
Since G2 already does add a guideline at the mouse position, just ask Georg to add a modifier key to set it to the italic angle when the guide is added. No need for a script then.
Look at docu.glyphsapp.com, especially at the viewPort and selectedLayerOrigin. And there’s documentation about the Edit view scale as well.
Hi! I’m trying to get the current cursor position from a script, which I run with a shortcut via Better Touch Tool, but instead of the actual mouse position, the code (below) returns the bottom left corner. Doing the same with the regular macOS shortcuts works correctly, so obviously BTT messes it up. I wonder if that can be somehow fixed, perhaps I can update something in the script before requesting the cursor? I see there’s graphicView.cursorUpdate_() but no idea what’s the argument.
BTT otherwise doesn’t cause any problems with the cursor, MOUSEMOVED works fine, so I assume the script misses the updated position, right?
graphicView = Font.currentTab.graphicView()
cursor = graphicView.getActiveLocation_(Glyphs.currentEvent())
Any chance you have an idea?
Can you show your code how your script is called?
You can try to get the latest NSEvent like this:
Glyphs.currentEvent(). You should get the current mouse position from it.
graphicView.cursorUpdate_() is used to set the cursor image when the mouse is over the edit view. That is not what you want.
For some reason running
print(Glyphs.currentEvent()) via a BTT shortcut returns
None. Is it possible to create that event from the code? Perhaps, trigger MOUSEMOVED or something like that?
It seems that the script is called in a way that prevents the usual cocoa methods. Maybe this helps: Cocoa: Getting the current mouse position on the screen - Stack Overflow