示例#1
0
 def controlChanged(self, info):
     
     # Make sure the RoboControlInput notificaiton is for the desired control name:
     if info["name"] == self.controlName:
         
         # Figure out some info about the current glyph, and current glyph window
         glyph = CurrentGlyph()
         font = CurrentFont()
         glyphOrder = []
         if font:
             glyphOrder = font.lib["public.glyphOrder"]
         
         # If there's a glyph window open:
         w = CurrentGlyphWindow()
         if w:
             # Find this glyph's index in the glyphOrder
             thisGlyphIndex = glyphOrder.index(glyph.name)
             prevGlyphIndex = thisGlyphIndex - 1
             nextGlyphIndex = thisGlyphIndex + 1
             if nextGlyphIndex == len(glyphOrder):
                 nextGlyphIndex = 0
             elif prevGlyphIndex < 0:
                 prevGlyphIndex = len(glyphOrder) - 1
             # Then, find the previous/next glyph names
             prevGlyphName = glyphOrder[prevGlyphIndex]
             nextGlyphName = glyphOrder[nextGlyphIndex]
             
             # Now that we know something about the current glyph and its neighbors:
             if info["value"] == "cw":
                 # Move clockwise, next glypyh
                 w.setGlyphByName(nextGlyphName)
             elif info["value"] == "ccw":
                 # Counter-clockwise, prev glyph
                 w.setGlyphByName(prevGlyphName)
示例#2
0
 def mouseDown(self, info):
     if info["clickCount"] == 2:
         if not self.currentGlyph == None:
             mouseLoc = (info["point"].x, info["point"].y)
             if not self.previousGlyph == None:
                 # There's a previous glyph being drawn, check to see if the double click is in its bouds
                 if self.inBounds(mouseLoc, self.previousGlyph.bounds,
                                  self.currentGlyph.width):
                     cgw = CurrentGlyphWindow()
                     cgw.setGlyphByName(self.previousGlyph.name)
             else:
                 # Check the components
                 for c in self.currentGlyph.components:
                     if c.selected:  # First click should select it
                         if self.inBounds(mouseLoc, c.bounds):
                             self.didSwitch = True
                             cgw = CurrentGlyphWindow()
                             cgw.setGlyphByName(c.baseGlyph)