Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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