I updated my script “Edit Next Glyph” and found that centering the current glyph in the tab did not work reliably. Strangely, it turned out that a simple print() at the right time fixes the problem:
Can anyone shed some light on this? Why is this necessary? Is there a more elegant way of triggering whatever print() seems to trigger? Thanks!
Removing or commenting out only the print() does not work as the Python interpreter will complain, of course, so to test this you need to remove the entire condition.
Something is funny with the forum software. Even the Dropbox link with dl=1 is not preserved as a link. Something is trying to be too smart but it fails. Can I prevent it from trying to embed the video?
Now I understand. The problem is only why the first position. And only really visible at certain zoom sizes.
I had a look. It seems that Glyphs is trying to keep the selected layer visible when in Text mode and scrolls it into place. That interferes with your attempt to center it. As long as the newly selected layer is not touching the border of the view, Glyphs doesn’t do anything. Zoom out so that all glyphs fit and a bit more. Then the centering should work.
So when you are in selection/edit more, the script should work just fine.
Calling .redraw is not actually redrawing, it just markes the view that it needs to be redrawn in the next drawing cycle. That is how macOS works. Calling print() deals with the runloop to get an extra redraw cycle.