Is there a method to put the focus of a script-wise opened new edit tab right on the caret? What I already do is open a tab, move the caret/cursor several times to the right*, and set the point size. Since the string in the tab is very long, Glyphs’ default behaviour of centering the view gets in my way of focusing a certain position in that string. Any thoughts?
Is there another way to get the caret to a certain position in an edit tab? Index, glyph name, what ever?
And how can I set the tool to T (text) via code? I could find methods like setSelectedToolIndex_(), but this might not always be the best way if someone has plugins in the tool bar.
*)
for i in range(5):
Glyphs.font.tabs[-1].graphicView().textStorage().moveRight_(True)
This is what I do here, .moveRight() doesn’t take an int, or at least doesn’t react differently with True, 1, or 5 as arguments.
Concerning setting the caret: You do not need to resort to the Text Tool. You simply set the selectedRange of the current graphic view to an NSRange of your liking.
And I reread your question 1 a few times now, but I still have no idea what you are trying to achieve. Or does accessing Graphic View directly solve your problems?
That is something I already thought about. Having no actual range, but only the position made me assume it could be too hacky. But it is a nice way.
Basically in the end I want to put the caret into the last line and at a certain position (which i could read out in the code), so the location won’t be so easily as defining it as 2 or 5 or so.
Oh, let me try to explain a bit better: Once I open a new tab with a very long string, Glyphs itself arranges the view to be somewhere in the middle of this long string. But I want to see the caret right on spot. Here is a sketch:
new Tab:
*blablablabl * = caret
blablablabla
blablablabla <–– outside the screen
blablablabla
··················
blablablabla
blablablabla <–– inside the screen
blablablabla
blablablabla
··················
blablablabla <–– outside the screen
blablablabla
blablablabla
blablablabla
(in Text Mode) I is there is a way to access the next Glyph in a string, but instead of just moving the caret, to enter the editing mode (eg. double clicking).