From e3a3a8765cc037eb0c4d2e9c451585f37d6d306b Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 15 Dec 2018 16:26:21 -0500 Subject: [PATCH] Remove destroyed widgets from mouse over list --- piker/ui/kivy/mouse_over.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/piker/ui/kivy/mouse_over.py b/piker/ui/kivy/mouse_over.py index 80a67d63..8b472ce7 100644 --- a/piker/ui/kivy/mouse_over.py +++ b/piker/ui/kivy/mouse_over.py @@ -89,14 +89,17 @@ class MouseOverBehavior(object): def __init__(self, **kwargs): self.register_event_type('on_enter') self.register_event_type('on_leave') - MouseOverBehavior._widgets.append(self) super().__init__(**kwargs) Window.bind(mouse_pos=self._on_mouse_pos) + self._widgets.append(self) + + def __del__(self): + MouseOverBehavior.remove(self) @classmethod # try throttling to 1ms latency (doesn't seem to work - # best I can get is 0.01...) - @triggered(timeout=0.001, interval=False) + # best I can get is 0.01 ?) + @triggered(timeout=0.015, interval=False) def _on_mouse_pos(cls, *args): log.debug(f"{cls} time since last call: {time.time() - cls._last_time}") cls._last_time = time.time() @@ -107,10 +110,11 @@ class MouseOverBehavior(object): pos = args[1] # Next line to_widget allow to compensate for relative layout - for widget in cls._widgets.copy(): + for widget in cls._widgets: w_coords = widget.to_widget(*pos) inside = widget.collide_point(*w_coords) if inside and widget.hovered: + log.debug('already hovered') return elif inside: # un-highlight the last highlighted