Skip to content

Instantly share code, notes, and snippets.

@typemytype
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save typemytype/75fe988b9258f8de41b5 to your computer and use it in GitHub Desktop.

Select an option

Save typemytype/75fe988b9258f8de41b5 to your computer and use it in GitHub Desktop.
Open the selected component base glyph in a separate glyph window
from mojo.UI import OpenGlyphWindow
from mojo.events import addObserver
class BaseGlyphJumper(object):
def __init__(self):
# add observer on key down
addObserver(self, "keyDown", "keyDown")
def keyDown(self, notification):
# get the event
event = notification["event"]
# get the pressed character
char = event.characters()
# check it agains a predefined character
if char == "C": # capital 'c' --> shift 'c'
# get the glyph
glyph = notification["glyph"]
# get the parent font
font = glyph.getParent()
# loop over all components
for component in glyph.components:
# check if the component is selected
if component.selected:
# check if the base glyph is in the font
if component.baseGlyph in font:
# get the base glyph as an glyph object
baseGlyph = font[component.baseGlyph]
# open a new glyph window with the base glyph
OpenGlyphWindow(baseGlyph, newWindow=True)
# go!
BaseGlyphJumper()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment