diff --git a/examples/reacting_to_entering_and_leaving.py b/examples/reacting_to_entering_and_leaving.py index 5d7fc6c..f51da33 100644 --- a/examples/reacting_to_entering_and_leaving.py +++ b/examples/reacting_to_entering_and_leaving.py @@ -1,4 +1,4 @@ -from kivy.utils import reify +from functools import cached_property from kivy.properties import NumericProperty from kivy.app import App from kivy.lang import Builder @@ -95,7 +95,7 @@ class ReactiveDroppableBehavior(KXDroppableBehavior): ''' __events__ = ('on_drag_enter', 'on_drag_leave', ) - @reify + @cached_property def __ud_key(self): return 'ReactiveDroppableBehavior.' + str(self.uid) @@ -107,9 +107,7 @@ def on_touch_move(self, touch): if drag_cls is not None: touch_ud[ud_key] = None if drag_cls in self.drag_classes: - # Start watching the touch. Use ``ak.or_()`` so that ``_watch_touch()`` will be automatically - # cancelled when the drag is cancelled. - ak.start(ak.or_( + ak.start(ak.wait_any( self._watch_touch(touch), ak.event(touch.ud['kivyx_draggable'], 'on_drag_end'), )) @@ -122,8 +120,8 @@ async def _watch_touch(self, touch): self.dispatch('on_drag_enter', touch, ctx, draggable) try: - async with ak.watch_touch(self, touch) as is_touch_move: - while await is_touch_move(): + async with ak.watch_touch(self, touch) as in_progress: + while await in_progress(): if not collide_point(*touch.pos): return finally: diff --git a/examples/reorderable_stacklayout.py b/examples/reorderable_stacklayout.py index 37fbe25..db699e2 100644 --- a/examples/reorderable_stacklayout.py +++ b/examples/reorderable_stacklayout.py @@ -1,8 +1,7 @@ ''' -When you want to make ``StackLayout`` re-orderable, you may want to disable -the ``size_hint`` of each child, or may want to limit the maximum size of -each child, otherwise the layout may be messed up. You can confirm it by -commenting/uncommenting the ``SampleApp.on_start()``'s body. +When you want to make a :class:`kivy.uix.stacklayout.StackLayout` re-orderable, you may want to disable the +``size_hint`` of each child, or may want to limit the maximum size of each child, otherwise the layout will be messed +up. You can confirm that by commenting/uncommenting the part of ``SampleApp.on_start()``. ''' from kivy.lang import Builder diff --git a/src/kivy_garden/draggable/_impl.py b/src/kivy_garden/draggable/_impl.py index 3abcb31..1de2ff9 100644 --- a/src/kivy_garden/draggable/_impl.py +++ b/src/kivy_garden/draggable/_impl.py @@ -140,7 +140,7 @@ def start_dragging_from_others_touch(self, receiver: Widget, touch): --------- * ``receiver`` ... The widget that received the ``touch``. - * ``touch`` ... A touch that is going to drag me. + * ``touch`` ... The touch that is going to drag me. ''' if touch.time_end != -1: return @@ -370,9 +370,7 @@ def on_touch_move(self, touch): if drag_cls is not None: touch_ud[ud_key] = None if drag_cls in self.drag_classes: - # Start watching the touch. Use ``ak.or_()`` so that ``_watch_touch()`` will be automatically - # cancelled when the drag is cancelled. - ak.start(ak.or_( + ak.start(ak.wait_any( self._watch_touch(touch), ak.event(touch.ud['kivyx_draggable'], 'on_drag_end'), )) @@ -395,8 +393,8 @@ async def _watch_touch(self, touch): touch_ud['kivyx_drag_ctx'].original_state, ignore_parent=True) add_widget(spacer) - async with ak.watch_touch(self, touch) as is_touch_move: - while await is_touch_move(): + async with ak.watch_touch(self, touch) as in_progress: + while await in_progress(): x, y = touch.pos if collide_point(x, y): new_idx = get_drop_insertion_index_move(x, y, spacer)