Skip to content

Commit

Permalink
Fixed on_long_touch method call
Browse files Browse the repository at this point in the history
The `on_long_touch` method was called at the `on_touch_down` event.
  • Loading branch information
HeaTTheatR committed Oct 24, 2022
1 parent fbb01d8 commit 90d7e1b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions kivymd/uix/behaviors/touch_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from kivymd.uix.button import MDRaisedButton
KV = '''
Screen:
MDScreen:
MyButton:
text: "PRESS ME"
Expand Down Expand Up @@ -74,9 +74,10 @@ def __init__(self, **kwargs):

def create_clock(self, widget, touch, *args):
if self.collide_point(touch.x, touch.y):
callback = partial(self.on_long_touch, touch)
Clock.schedule_once(callback, self.duration_long_touch)
touch.ud["event"] = callback
if "event" not in touch.ud:
callback = partial(self.on_long_touch, touch)
Clock.schedule_once(callback, self.duration_long_touch)
touch.ud["event"] = callback

if touch.is_double_tap:
self.on_double_tap(touch, *args)
Expand All @@ -85,10 +86,9 @@ def create_clock(self, widget, touch, *args):

def delete_clock(self, widget, touch, *args):
if self.collide_point(touch.x, touch.y):
try:
if "event" in touch.ud:
Clock.unschedule(touch.ud["event"])
except KeyError:
pass
del touch.ud["event"]

def on_long_touch(self, touch, *args):
"""Called when the widget is pressed for a long time."""
Expand Down

0 comments on commit 90d7e1b

Please sign in to comment.