diff --git a/src/kivy_garden/draggable/_impl.py b/src/kivy_garden/draggable/_impl.py index 26b8a24..3abcb31 100644 --- a/src/kivy_garden/draggable/_impl.py +++ b/src/kivy_garden/draggable/_impl.py @@ -19,7 +19,7 @@ import asynckivy as ak from ._utils import ( - temp_transform, temp_grab_current, _create_spacer, + temp_transform, _create_spacer, save_widget_state, restore_widget_state, ) @@ -228,10 +228,13 @@ async def _treat_a_touch_as_a_drag(self, touch, *, do_transform=False, touch_rec async def _simulate_a_normal_touch(self, touch, *, do_transform=False, do_touch_up=False): # simulate 'on_touch_down' - with temp_grab_current(touch): + original = touch.grab_current + try: touch.grab_current = None with temp_transform(touch, self.parent.to_widget) if do_transform else nullcontext(): super().on_touch_down(touch) + finally: + touch.grab_current = original if not do_touch_up: return diff --git a/src/kivy_garden/draggable/_utils.py b/src/kivy_garden/draggable/_utils.py index 23215a3..3122b83 100644 --- a/src/kivy_garden/draggable/_utils.py +++ b/src/kivy_garden/draggable/_utils.py @@ -1,5 +1,5 @@ __all__ = ( - 'temp_transform', 'temp_grab_current', + 'temp_transform', 'save_widget_state', 'restore_widget_state', 'save_widget_location', 'restore_widget_location', ) @@ -24,20 +24,6 @@ def __exit__(self, *args): self._touch.pop() -class temp_grab_current: - __slots__ = ('_touch', '_original', ) - - def __init__(self, touch): - self._touch = touch - self._original = touch.grab_current - - def __enter__(self): - pass - - def __exit__(self, *args): - self._touch.grab_current = self._original - - _shallow_copyable_property_names = ( 'x', 'y', 'width', 'height', 'size_hint_x', 'size_hint_y',