Skip to content

Commit 9147d30

Browse files
committed
Fixed osgWidget event handling
1 parent 711d69d commit 9147d30

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/osgWidget/WindowManager.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,17 @@ bool WindowManager::pickAtXY(float x, float y, WidgetList& wl)
317317
// Iterate over every picked result and create a list of Widgets that belong
318318
// to that Window.
319319
for(Intersections::iterator i = intr.begin(); i != intr.end(); i++) {
320-
Window* win = dynamic_cast<Window*>(i->nodePath.back()->getParent(0));
320+
321+
Widget* widget = dynamic_cast<Widget*>(i->drawable.get());
322+
if(!widget) continue;
323+
324+
Window* win = 0;
325+
const osg::NodePath& nodePath = i->nodePath;
326+
for(osg::NodePath::const_reverse_iterator np_itr = nodePath.rbegin(); np_itr != nodePath.rend(); ++np_itr)
327+
{
328+
win = dynamic_cast<Window*>(*np_itr);
329+
if (win) break;
330+
}
321331

322332
// Make sure that our window is valid, and that our pick is within the
323333
// "visible area" of the Window.
@@ -335,9 +345,6 @@ bool WindowManager::pickAtXY(float x, float y, WidgetList& wl)
335345
// If we've found a new Widnow, break out!
336346
else if(activeWin != win) break;
337347

338-
Widget* widget = dynamic_cast<Widget*>(i->drawable.get());
339-
340-
if(!widget) continue;
341348

342349
// We need to return a list of every Widget that was picked, so
343350
// that the handler can operate on it accordingly.

0 commit comments

Comments
 (0)