Skip to content

Commit

Permalink
remove temp_grab_current (private api)
Browse files Browse the repository at this point in the history
  • Loading branch information
gottadiveintopython committed Aug 28, 2023
1 parent 3c88f47 commit 3fc8988
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
7 changes: 5 additions & 2 deletions src/kivy_garden/draggable/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions src/kivy_garden/draggable/_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = (
'temp_transform', 'temp_grab_current',
'temp_transform',
'save_widget_state', 'restore_widget_state',
'save_widget_location', 'restore_widget_location',
)
Expand All @@ -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',
Expand Down

0 comments on commit 3fc8988

Please sign in to comment.