def cancelMode(self): debugPrint('cancelMode') natlink.setTrayIcon() if self.inTimer: natlinktimer.setTimerCallback(self.onTimer, 0) self.inTimer = 0 if self.drag: debugPrint('switch of dragging') xPos, yPos = natlink.getCursorPos() if self.drag == 2: natlink.playEvents([(natlinkutils.wm_rbuttonup, xPos, yPos) ]) else: natlink.playEvents([(natlinkutils.wm_lbuttonup, xPos, yPos) ]) self.drag = 0 elif self.state == 'searching': self.stopSearch() self.state = '' self.minorState = '' self.curDir = '' self.Count = 0 self.mouseSteps = 10 self.inside = 0 self.insideCommand = 0 self.waiting = 0 self.drag = 0 self.repeatFlag = 0 self.hadRepeat = 0 self.repeatStuff = None self.lastResults = [] self.activateSet(normalSet, exclusive=0)
def cancelMode(self): self.curMode = None if self.haveCallback: natlink.setTimerCallback(None,0) self.haveCallback = 0 self.activateSet(['start'],exclusive=0) natlink.setTrayIcon()
def setTrayIcon(self,toggleIcon): iconName = self.curDirection toolTip = 'moving '+self.curDirection if not toggleIcon or self.iconState: self.iconState = 0 else: self.iconState = 1 iconName = iconName + '2' natlink.setTrayIcon(iconName,toolTip,self.onTrayIcon)
def setTrayIcon(self, toggleIcon): if self.state in [ 'moving', 'selecting', 'mousing', 'dragging', 'searching' ]: iconName = self.curDir toolTip = self.state + ' ' + self.curDir elif self.state == 'repeating': toolTip = 'repeating commands' iconName = os.path.join(iconDirectory, 'repeat') else: natlink.setTrayIcon() print('setTrayIcon, invalid state:', self.state) return if self.waiting: toolTip = 'WAITING' if not toggleIcon or self.iconState: self.iconState = 0 else: self.iconState = 1 if self.waiting: iconName = os.path.join(iconDirectory, 'waiting') else: iconName = iconName + '2' ## print 'iconName: %s'% iconName try: if iconName[1] == ':': # absolute path, attach extension: iconName = iconName + '.ico' except IndexError: print('cannot set tray icon, no iconName (_repeat), try to clear') natlink.setTrayIcon() try: natlink.setTrayIcon(iconName, toolTip, self.onTrayIcon) except natlink.NatError: print('cannot set tray icon (_repeat), try to clear') natlink.setTrayIcon()
def doNextIcon(self): if self.stopShowing: print 'caught callback, stop the looping' natlink.setTrayIcon() natlink.setTimerCallback(None) return if self.currentLoop >= self.loops: self.currentLoop = 0 self.currentDirection += 1 if self.currentDirection >= len(self.directions): print 'ready all done, remove the icon and stop the timercallback' natlink.setTrayIcon() natlink.setTimerCallback(None) if self.currentLoop % 2: iconName = '%s2' % self.directions[self.currentDirection] else: iconName = '%s' % self.directions[self.currentDirection] print 'set trayIcon: %s' % iconName natlink.setTrayIcon(iconName, 'test also click on icon %s' % iconName, self.onTrayIcon)