#include "CanvasEvent.hxx"
#include "CanvasEventVisitor.hxx"
#include <simgear/canvas/elements/CanvasElement.hxx>
-#include <iostream>
namespace simgear
{
_root(root)
{
if( mode == TRAVERSE_DOWN )
- {
- EventTarget target = {ElementWeakPtr(), pos};
- _target_path.push_back(target);
- }
+ _target_path.push_back( EventTarget(NULL, pos) );
}
//----------------------------------------------------------------------------
// catch all events which have no target. This allows for example calling
// event listeners attached to the canvas itself (its root group) even if
// no element has been hit.
- if( _root.get() != &el && !el.hitBound(pos, local_pos) )
+ if( _root.get() != &el
+ && !el.hitBound(_target_path.front().local_pos, pos, local_pos) )
return false;
- EventTarget target = {el.getWeakPtr(), local_pos};
- _target_path.push_back(target);
+ _target_path.push_back( EventTarget(&el, local_pos) );
if( el.traverse(*this) || &el == _root.get() )
return true;