def select(self): super().select() self._savedval = self._val self._val = 0 self._updateText(True) self.touchAsset() MathApp.listenKeyEvent("keypress", "*", self.processEvent)
def select(self): super().select() if not self._leftctrl: MathApp.listenKeyEvent("keydown", "left arrow", self._moveLeft) if not self._rightctrl: MathApp.listenKeyEvent("keydown", "right arrow", self._moveRight) MathApp.listenMouseEvent("click", self._mouseClick)
def __init__(self, *args, **kwargs): super().__init__(RectangleAsset(1, 1), *args, **kwargs) self._val = self._nposinputs.initial() self._steps = kwargs.get('steps', 50) self._step = (self._nposinputs.maxval() - self._nposinputs.minval()) / self._steps self._leftctrl = kwargs.get('leftkey', None) self._rightctrl = kwargs.get('rightkey', None) self._centerctrl = kwargs.get('centerkey', None) self.selectable = True # must be after super init! self.strokable = True # this enables grabbing/slideing the thumb self.thumbcaptured = False self._thumbwidth = max(self._stdinputs.width() / 40, 1) self._thumb = Sprite( RectangleAsset(self._thumbwidth, self._stdinputs.size() - 2, LineStyle(1, self._stdinputs.color()), self._stdinputs.color()), self._thumbXY()) self._touchAsset() if self._leftctrl: MathApp.listenKeyEvent("keydown", self._leftctrl, self.moveLeft) if self._rightctrl: MathApp.listenKeyEvent("keydown", self._rightctrl, self.moveRight) if self._centerctrl: MathApp.listenKeyEvent("keydown", self._centerctrl, self.moveCenter)
def __init__(self, *args, **kwargs): super().__init__(RectangleAsset(1, 1), *args, **kwargs) self._val = self._nposinputs.initial() # pylint: disable=no-member self._steps = kwargs.get("steps", 50) self._step = ( self._nposinputs.maxval() # pylint: disable=no-member - self._nposinputs.minval() # pylint: disable=no-member ) / self._steps self._leftctrl = kwargs.get("leftkey", None) self._rightctrl = kwargs.get("rightkey", None) self._centerctrl = kwargs.get("centerkey", None) self.selectable = True # must be after super init! self.strokable = True # this enables grabbing/slideing the thumb self.thumbcaptured = False self._thumbwidth = max(self._stdinputs.width() / 40, 1) self._thumb = Sprite( RectangleAsset( self._thumbwidth, self._stdinputs.size() - 2, LineStyle(1, self._stdinputs.color()), self._stdinputs.color(), ), self._thumbXY(), ) self.touchAsset() if self._leftctrl: MathApp.listenKeyEvent("keydown", self._leftctrl, self._moveLeft) if self._rightctrl: MathApp.listenKeyEvent("keydown", self._rightctrl, self._moveRight) if self._centerctrl: MathApp.listenKeyEvent("keydown", self._centerctrl, self._moveCenter)