From a79f54a2deac05f0df1b8a91207fb408eda8dfac Mon Sep 17 00:00:00 2001 From: pythonic64 Date: Sat, 27 Dec 2025 19:07:50 +0100 Subject: [PATCH 1/3] HoverManager: Renamed min_wait_time to event_repeat_timeout. --- kivy_garden/hover/__init__.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/kivy_garden/hover/__init__.py b/kivy_garden/hover/__init__.py index 8c2e6ce..3274eea 100644 --- a/kivy_garden/hover/__init__.py +++ b/kivy_garden/hover/__init__.py @@ -14,39 +14,41 @@ class HoverManager(EventManagerBase): children list using `on_motion` widget event. To handle case when hover event position has not changed within - `min_wait_time` manager will re-dispatch with all delta values set to 0 and - therefore enabling widgets to re-handle the event. This is useful for case - when mouse is used the scroll a recycle list of widgets but the mouse - indicator position is not changing. + `event_repeat_timeout` manager will re-dispatch with all delta values set + to 0 and therefore enabling widgets to re-handle the event. This is useful + for the case when mouse is used the scroll a recycle list of widgets, but + the mouse indicator position is not changing. """ type_ids = ('hover',) - min_wait_time = 1/30.0 - """Minimum wait time to repeat existing hover events and defaults to - `1/30.0` seconds. Negative value will turn off the feature. + event_repeat_timeout = 1 / 30.0 + """Minimum wait time to repeat existing static hover events and it + defaults to `1/30.0` seconds. Negative value will turn off the feature. - To change the default value use `min_wait_time` keyword while making a + To change the default value use `event_repeat_timeout` keyword while making a manager instance or set it directly after the instance is made. Changing the value after the manager has started will have no effect. """ def __init__(self, **kwargs): super().__init__() - self.min_wait_time = kwargs.get('min_wait_time', - HoverManager.min_wait_time) + self.event_repeat_timeout = kwargs.get( + 'event_repeat_timeout', + HoverManager.event_repeat_timeout + ) self._events = defaultdict(list) # me.uid -> [(me, me.grab_list[:]),] self._event_times = {} # me.uid -> Clock.get_time() self._clock_event = None def start(self): - if self.min_wait_time >= 0: + if self.event_repeat_timeout >= 0: global Clock if not Clock: from kivy.clock import Clock self._clock_event = Clock.schedule_interval( self._dispatch_from_clock, - self.min_wait_time + self.event_repeat_timeout ) def stop(self): @@ -128,7 +130,7 @@ def _dispatch_from_clock(self, *args): events_to_update = [] for me_id, items in self._events.items(): me, _ = items[0] - if time_now - times[me.uid] < self.min_wait_time: + if time_now - times[me.uid] < self.event_repeat_timeout: continue events_to_update.append(me) for me in events_to_update: From 8a1bd58407158839f4d30ae9ac0a3dc0bc5c8134 Mon Sep 17 00:00:00 2001 From: pythonic64 Date: Sat, 27 Dec 2025 19:53:00 +0100 Subject: [PATCH 2/3] HoverManager: Updated class doc. --- kivy_garden/hover/__init__.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/kivy_garden/hover/__init__.py b/kivy_garden/hover/__init__.py index 3274eea..ae6d8e2 100644 --- a/kivy_garden/hover/__init__.py +++ b/kivy_garden/hover/__init__.py @@ -7,17 +7,18 @@ class HoverManager(EventManagerBase): - """Manager for dispatching hover events through window children list. + """Manager for dispatching hover events to widgets in the window children + list. When registered, manager will receive all events with `type_id` set to - "hover", transform them to match :attr:`window` and dispatch them through - children list using `on_motion` widget event. - - To handle case when hover event position has not changed within - `event_repeat_timeout` manager will re-dispatch with all delta values set - to 0 and therefore enabling widgets to re-handle the event. This is useful - for the case when mouse is used the scroll a recycle list of widgets, but - the mouse indicator position is not changing. + "hover", transform them to match :attr:`window` size and dispatch them + through the `window.children` list using the `on_motion` event. + + To handle a case when the hover event position did not change within + `event_repeat_timeout` seconds, manager will re-dispatch the event with all + delta values set to 0, so that widgets can re-handle the event. + This is useful for the case when a mouse is used to scroll a recyclable + list of widgets, but the mouse indicator position is not changing. """ type_ids = ('hover',) @@ -26,8 +27,8 @@ class HoverManager(EventManagerBase): """Minimum wait time to repeat existing static hover events and it defaults to `1/30.0` seconds. Negative value will turn off the feature. - To change the default value use `event_repeat_timeout` keyword while making a - manager instance or set it directly after the instance is made. Changing + To change the default value use `event_repeat_timeout` keyword while making + a manager instance or set it directly after the instance is made. Changing the value after the manager has started will have no effect. """ From df92fb836f17154e4959d21679b27efaf8a7387f Mon Sep 17 00:00:00 2001 From: pythonic64 Date: Sun, 28 Dec 2025 15:38:50 +0100 Subject: [PATCH 3/3] HoverManager: Removed comment in _dispatch_to_grabbed_widgets method. --- kivy_garden/hover/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kivy_garden/hover/__init__.py b/kivy_garden/hover/__init__.py index ae6d8e2..2881415 100644 --- a/kivy_garden/hover/__init__.py +++ b/kivy_garden/hover/__init__.py @@ -86,7 +86,6 @@ def _dispatch_to_widgets(self, etype, me): return accepted def _dispatch_to_grabbed_widgets(self, me, prev_me_grab_list): - # Dispatch 'end' event to widgets in prev_me_grab_list prev_grab_state = me.grab_state prev_time_end = me.time_end me_grab_list = me.grab_list[:] @@ -96,9 +95,8 @@ def _dispatch_to_grabbed_widgets(self, me, prev_me_grab_list): for weak_widget in prev_me_grab_list: if weak_widget not in me_grab_list: widget = weak_widget() - if not widget: - continue - self._dispatch_to_widget('end', me, widget) + if widget: + self._dispatch_to_widget('end', me, widget) me.grab_list[:] = me_grab_list me.grab_state = prev_grab_state me.time_end = prev_time_end