mirror of https://github.com/kivy/kivy.git
mouse: extend mouse input to add button profile. Now scrolldown/scrollup button are available in touch.button
This commit is contained in:
parent
9c6e0dde5c
commit
86b0856bd4
|
@ -212,6 +212,10 @@ class WindowPygame(WindowBase):
|
||||||
btn = 'right'
|
btn = 'right'
|
||||||
elif event.button == 2:
|
elif event.button == 2:
|
||||||
btn = 'middle'
|
btn = 'middle'
|
||||||
|
elif event.button == 4:
|
||||||
|
btn = 'scrolldown'
|
||||||
|
elif event.button == 5:
|
||||||
|
btn = 'scrollup'
|
||||||
eventname = 'on_mouse_down'
|
eventname = 'on_mouse_down'
|
||||||
if event.type == pygame.MOUSEBUTTONUP:
|
if event.type == pygame.MOUSEBUTTONUP:
|
||||||
eventname = 'on_mouse_up'
|
eventname = 'on_mouse_up'
|
||||||
|
|
|
@ -55,6 +55,8 @@ providers to know if they are other profiles available.
|
||||||
Profile name Description
|
Profile name Description
|
||||||
-------------- ----------------------------------------------------------------
|
-------------- ----------------------------------------------------------------
|
||||||
angle 2D angle. Use property `a`
|
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`
|
markerid Marker or Fiducial ID. Use property `fid`
|
||||||
pos 2D position. Use properties `x`, `y`
|
pos 2D position. Use properties `x`, `y`
|
||||||
pos3d 3D position. Use properties `x`, `y`, `z`
|
pos3d 3D position. Use properties `x`, `y`, `z`
|
||||||
|
|
|
@ -31,9 +31,11 @@ Color = Ellipse = None
|
||||||
class MouseMotionEvent(MotionEvent):
|
class MouseMotionEvent(MotionEvent):
|
||||||
|
|
||||||
def depack(self, args):
|
def depack(self, args):
|
||||||
self.profile = ['pos']
|
self.profile = ['pos', 'button']
|
||||||
self.is_touch = True
|
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)
|
super(MouseMotionEvent, self).depack(args)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -125,11 +127,11 @@ class MouseMotionEventProvider(MotionEventProvider):
|
||||||
return t
|
return t
|
||||||
return False
|
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
|
self.counter += 1
|
||||||
id = 'mouse' + str(self.counter)
|
id = 'mouse' + str(self.counter)
|
||||||
self.current_drag = cur = MouseMotionEvent(
|
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
|
cur.is_double_tap = is_double_tap
|
||||||
self.touches[id] = cur
|
self.touches[id] = cur
|
||||||
if do_graphics:
|
if do_graphics:
|
||||||
|
@ -172,7 +174,7 @@ class MouseMotionEventProvider(MotionEventProvider):
|
||||||
else:
|
else:
|
||||||
is_double_tap = 'shift' in modifiers
|
is_double_tap = 'shift' in modifiers
|
||||||
do_graphics = (button != 'left' or ('ctrl' 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:
|
if 'alt' in modifiers:
|
||||||
self.alt_touch = cur
|
self.alt_touch = cur
|
||||||
self.current_drag = None
|
self.current_drag = None
|
||||||
|
@ -183,7 +185,8 @@ class MouseMotionEventProvider(MotionEventProvider):
|
||||||
rx = x / float(width)
|
rx = x / float(width)
|
||||||
ry = 1. - y / float(height)
|
ry = 1. - y / float(height)
|
||||||
cur = self.find_touch(rx, ry)
|
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.remove_touch(cur)
|
||||||
self.current_drag = None
|
self.current_drag = None
|
||||||
if self.alt_touch:
|
if self.alt_touch:
|
||||||
|
|
Loading…
Reference in New Issue