#mouse.py
from kivy.app import App
from kivy.uix.widget import Widget
class Touch(Widget):
def on_touch_down(self, touch):
print("Mouse Down", touch)
self.ids["button_id"].opacity = 0.5
def on_touch_move(self, touch):
print("Mouse Move", touch)
def on_touch_up(self, touch):
print("Mouse Up", touch)
self.ids["button_id"].opacity = 1
class MouseApp(App):
def build(self):
return Touch()
MouseApp().run()
---------------------------\
mouse.kv
<Touch>
Button:
id:button_id
size: root.width-200, root.height-200
pos: 100, 100
text:"Button"
---------------
#logs
Mouse Down <MouseMotionEvent spos=(0.35875, 0.5516666666666667) pos=(287.0, 331.00000000000006)>
Mouse Up <MouseMotionEvent spos=(0.35875, 0.5516666666666667) pos=(287.0, 331.00000000000006)>
Mouse Down <MouseMotionEvent spos=(0.30125, 0.32833333333333337) pos=(241.0, 197.00000000000003)>
Mouse Move <MouseMotionEvent spos=(0.305, 0.32999999999999996) pos=(244.0, 197.99999999999997)>
Mouse Move <MouseMotionEvent spos=(0.3075, 0.33166666666666667) pos=(246.0, 199.0)>
reference:
No comments:
Post a Comment