]> git.mxchange.org Git - simgear.git/blobdiff - simgear/canvas/CanvasEventVisitor.cxx
canvas: BoxLayout shared pointer typedef.
[simgear.git] / simgear / canvas / CanvasEventVisitor.cxx
index 9fbae2c84a73a64a784bcdd2c2d5ccd6d68e68c2..efb12dbb49ad0073c0558d869765f75021dd17b6 100644 (file)
@@ -20,7 +20,6 @@
 #include "CanvasEvent.hxx"
 #include "CanvasEventVisitor.hxx"
 #include <simgear/canvas/elements/CanvasElement.hxx>
-#include <iostream>
 
 namespace simgear
 {
@@ -35,10 +34,7 @@ namespace canvas
     _root(root)
   {
     if( mode == TRAVERSE_DOWN )
-    {
-      EventTarget target = {ElementWeakPtr(), pos};
-      _target_path.push_back(target);
-    }
+      _target_path.push_back( EventTarget(NULL, pos) );
   }
 
   //----------------------------------------------------------------------------
@@ -69,11 +65,11 @@ namespace canvas
       // 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;