diff --git a/kivy/core/window/window_pygame.py b/kivy/core/window/window_pygame.py index 183e7cd11..ad9b6f71e 100644 --- a/kivy/core/window/window_pygame.py +++ b/kivy/core/window/window_pygame.py @@ -212,6 +212,10 @@ class WindowPygame(WindowBase): btn = 'right' elif event.button == 2: btn = 'middle' + elif event.button == 4: + btn = 'scrolldown' + elif event.button == 5: + btn = 'scrollup' eventname = 'on_mouse_down' if event.type == pygame.MOUSEBUTTONUP: eventname = 'on_mouse_up' diff --git a/kivy/input/motionevent.py b/kivy/input/motionevent.py index db6fd8e98..41084be0b 100644 --- a/kivy/input/motionevent.py +++ b/kivy/input/motionevent.py @@ -55,6 +55,8 @@ providers to know if they are other profiles available. Profile name Description -------------- ---------------------------------------------------------------- angle 2D angle. Use property `a` +button Mouse button (left, right, middle, scrollup, scrolldown) + Use property `button` markerid Marker or Fiducial ID. Use property `fid` pos 2D position. Use properties `x`, `y` pos3d 3D position. Use properties `x`, `y`, `z` diff --git a/kivy/input/providers/mouse.py b/kivy/input/providers/mouse.py index 14db276c1..f343c1cae 100644 --- a/kivy/input/providers/mouse.py +++ b/kivy/input/providers/mouse.py @@ -31,9 +31,11 @@ Color = Ellipse = None class MouseMotionEvent(MotionEvent): def depack(self, args): - self.profile = ['pos'] + self.profile = ['pos', 'button'] self.is_touch = True - self.sx, self.sy = args + self.sx, self.sy = args[:2] + if len(args) == 3: + self.button = args[2] super(MouseMotionEvent, self).depack(args) # @@ -125,11 +127,11 @@ class MouseMotionEventProvider(MotionEventProvider): return t return False - def create_touch(self, rx, ry, is_double_tap, do_graphics): + def create_touch(self, rx, ry, is_double_tap, do_graphics, button): self.counter += 1 id = 'mouse' + str(self.counter) self.current_drag = cur = MouseMotionEvent( - self.device, id=id, args=[rx, ry]) + self.device, id=id, args=[rx, ry, button]) cur.is_double_tap = is_double_tap self.touches[id] = cur if do_graphics: @@ -172,7 +174,7 @@ class MouseMotionEventProvider(MotionEventProvider): else: is_double_tap = 'shift' in modifiers do_graphics = (button != 'left' or ('ctrl' in modifiers)) - cur = self.create_touch(rx, ry, is_double_tap, do_graphics) + cur = self.create_touch(rx, ry, is_double_tap, do_graphics, button) if 'alt' in modifiers: self.alt_touch = cur self.current_drag = None @@ -183,7 +185,8 @@ class MouseMotionEventProvider(MotionEventProvider): rx = x / float(width) ry = 1. - y / float(height) cur = self.find_touch(rx, ry) - if button == 'left' and cur and not ('ctrl' in modifiers): + if button in ('left', 'scrollup', 'scrolldown') and cur and not ( + 'ctrl' in modifiers): self.remove_touch(cur) self.current_drag = None if self.alt_touch: