Skip to content

Commit

Permalink
Remove "use_draw_order" code path (#777)
Browse files Browse the repository at this point in the history
* dispatch should always just be _new_dispatch now

* remove _new_dispatch from documentation
  • Loading branch information
aaronayres35 authored Apr 16, 2021
1 parent 6120c85 commit a1a6059
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 59 deletions.
8 changes: 3 additions & 5 deletions docs/source/enable/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down
62 changes: 8 additions & 54 deletions enable/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a1a6059

Please sign in to comment.