def set_visible(self, visible):
     """
     Set visibility of mouse cursor. Return bool of previous state.
     """
     if visible:
         if not self.mouseCursor:
             DOM.setStyleAttribute(env.canvas.getElement(), 'cursor', 'default')
             self.mouseCursor = True
     else:
         if self.mouseCursor:
             DOM.setStyleAttribute(env.canvas.getElement(), 'cursor', 'none')
             self.mouseCursor = False
     return self.mouseCursor
 def set_visible(self, visible):
     """
     Set visibility of mouse cursor. Return bool of previous state.
     """
     if visible:
         if not self.mouseCursor:
             DOM.setStyleAttribute(env.canvas.getElement(), 'cursor',
                                   'default')
             self.mouseCursor = True
     else:
         if self.mouseCursor:
             DOM.setStyleAttribute(env.canvas.getElement(), 'cursor',
                                   'none')
             self.mouseCursor = False
     return self.mouseCursor
Esempio n. 3
0
 def _onMouseWheelY(self, sender, velocity):
     event = DOM.eventGetCurrentEvent()
     if velocity < 0:
         button = 4
         events = velocity / -3
     else:
         button = 5
         events = velocity / 3
     event.btn = button
     event.pos = (self.event.mouseMove['x'], self.event.mouseMove['y'])
     for evt in range(events):
         self.event._updateQueue(event)
Esempio n. 4
0
 def onMouseWheel(self, sender, velocity):
     event = DOM.eventGetCurrentEvent()
     if event.type == 'mousewheel':
         #TODO: update for changes in mousewheel implementation
         if hasattr(event, 'wheelDeltaX'):
             self.onMouseWheel = self._onMouseWheel
             self._onMouseWheel(sender, velocity)
         else:
             self.onMouseWheel = self._onMouseWheelY
             DOM.eventGetMouseWheelVelocityY = eventGetMouseWheelVelocityY
             self._onMouseWheelY(sender, eventGetMouseWheelVelocityY(event))
     else:       #DOMMouseScroll
         self.onMouseWheel = self._onMouseScroll
         self._onMouseScroll(sender, velocity)
Esempio n. 5
0
 def _onMouseScroll(self, sender, velocity):
     event = DOM.eventGetCurrentEvent()
     if velocity > 1 or velocity < -1:
         if velocity < 0:
             button = 4
         else:
             button = 5
     else:
         if velocity < 0:
             button = 6
         else:
             button = 7
     event.btn = button
     event.pos = (self.event.mouseMove['x'], self.event.mouseMove['y'])
     self.event._updateQueue(event)
Esempio n. 6
0
 def onKeyDown(self, sender, keycode, modifiers):
     if keycode in self.modKey:
         event = DOM.eventGetCurrentEvent()
         self.event.keyPress[keycode] = True
         self.event._updateQueue(event)
         DOM.eventPreventDefault(event)
     elif keycode in self.specialKey:
         event = DOM.eventGetCurrentEvent()
         self.event._updateQueue(event)
         DOM.eventPreventDefault(event)
Esempio n. 7
0
 def onMouseUp(self, sender, x, y):
     event = DOM.eventGetCurrentEvent()
     event.pos = (x, y)
     self.event.mousePress[event.button] = False
     self.event._updateQueue(event)
Esempio n. 8
0
 def onMouseMove(self, sender, x, y):
     event = DOM.eventGetCurrentEvent()
     event.pos = (x, y)
     self.event.mouseMove['x'], self.event.mouseMove['y'] = x, y
     self.event._updateQueue(event)
Esempio n. 9
0
 def onKeyUp(self, sender, keycode, modifiers):
     event = DOM.eventGetCurrentEvent()
     if keycode in self.modKey:
         self.event.keyPress[keycode] = False
     self.event._updateQueue(event)
Esempio n. 10
0
 def onKeyPress(self, sender, keycode, modifiers):
     event = DOM.eventGetCurrentEvent()
     if not (event.keyCode and event.keyCode in self.specialKey):
         self.event._updateQueue(event)
     DOM.eventPreventDefault(event)