From 31c40d3194383962a4aab5107d58797a14fe15c5 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 15 Apr 2021 11:31:10 -0700 Subject: [PATCH 1/2] dispatch should always just be _new_dispatch now --- enable/component.py | 62 ++++++--------------------------------------- 1 file changed, 8 insertions(+), 54 deletions(-) diff --git a/enable/component.py b/enable/component.py index c274eec1a..c53c78879 100644 --- a/enable/component.py +++ b/enable/component.py @@ -926,25 +926,6 @@ def _get_visible_border(self): def dispatch(self, event, suffix): """ Dispatches a mouse event based on the current event state. - Parameters - ---------- - event : an Enable MouseEvent - A mouse event. - suffix : string - The name of the mouse event as a suffix to the event state name, - e.g. "_left_down" or "_window_enter". - """ - - # This hasattr check is necessary to ensure compatibility with Chaco - # components. - if not getattr(self, "use_draw_order", True): - self._old_dispatch(event, suffix) - else: - self._new_dispatch(event, suffix) - - def _new_dispatch(self, event, suffix): - """ Dispatches a mouse event - If the component has a **controller**, the method dispatches the event to it, and returns. Otherwise, the following objects get a chance to handle the event: @@ -958,6 +939,14 @@ def _new_dispatch(self, event, suffix): If any object in this sequence handles the event, the method returns without proceeding any further through the sequence. If nothing handles the event, the method simply returns. + + Parameters + ---------- + event : an Enable MouseEvent + A mouse event. + suffix : string + The name of the mouse event as a suffix to the event state name, + e.g. "_left_down" or "_window_enter". """ # Maintain compatibility with .controller for now @@ -993,41 +982,6 @@ def _new_dispatch(self, event, suffix): for tool in self.tools: tool.dispatch(event, suffix) - def _old_dispatch(self, event, suffix): - """ Dispatches a mouse event. - - If the component has a **controller**, the method dispatches the event - to it and returns. Otherwise, the following objects get a chance to - handle the event: - - 1. The component's active tool, if any. - 2. Any listener tools. - 3. The component itself. - - If any object in this sequence handles the event, the method returns - without proceeding any further through the sequence. If nothing - handles the event, the method simply returns. - - """ - if self.controller is not None: - self.controller.dispatch(event, suffix) - return - - if self._active_tool is not None: - self._active_tool.dispatch(event, suffix) - - if event.handled: - return - - for tool in self.tools: - tool.dispatch(event, suffix) - if event.handled: - return - - if not event.handled: - self._dispatch_to_enable(event, suffix) - return - def _get_active_tool(self): return self._active_tool From a9206d8ad72a06d8291b4db1f0bd26716dc25318 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Fri, 16 Apr 2021 05:22:08 -0700 Subject: [PATCH 2/2] remove _new_dispatch from documentation --- docs/source/enable/overview.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/source/enable/overview.rst b/docs/source/enable/overview.rst index 5b7bc2ba9..ea0ab3fcd 100644 --- a/docs/source/enable/overview.rst +++ b/docs/source/enable/overview.rst @@ -117,11 +117,9 @@ is to dispatch to: 4. its underlays 5. its listener tools -That logic is in :class:`Component`, in the :meth:`\_new_dispatch` method, which -is called from :meth:`Component.dispatch` (:meth:`\_old_dispatch` is still -being used by Chaco). If any of these handlers sets event.handled to True, event -propagation stops. If an event gets as far as the listener tools, then all of -them get the event. +That logic is in :class:`Component`, in the :meth:`Component.dispatch`. If any +of these handlers sets event.handled to True, event propagation stops. If an +event gets as far as the listener tools, then all of them get the event. .. note::