// then we add its non-container components to the list of candidates;
// any nested containers are lower priority than primary plot components.
candidates = []
component = self.component
if isinstance(component, BasePlotContainer) or isinstance(component, BaseXYPlot):
candidates = get_nested_components(self.component)
elif isinstance(component, PlotAxis):
candidates = [(component, (0,0))]
else:
// We don"t support clicking on unrecognized components
return
// Hittest against all the candidate and take the first one
item = None
for candidate, offset in candidates:
if isinstance(candidate, PlotAxis):
if candidate.is_in(x-offset[0], y-offset[1]):
item = candidate
break
elif isinstance(candidate, BaseXYPlot):
if candidate.hittest((x-offset[0], y-offset[1])):
item = candidate
break
if item:
self.component.active_tool = self
item.edit_traits(kind="livemodal")
event.handled = True