Fixed osgWidget event handling

This commit is contained in:
Robert Osfield 2021-02-18 16:08:25 +00:00
parent 711d69d2fd
commit 9147d30515

View File

@ -317,7 +317,17 @@ bool WindowManager::pickAtXY(float x, float y, WidgetList& wl)
// Iterate over every picked result and create a list of Widgets that belong // Iterate over every picked result and create a list of Widgets that belong
// to that Window. // to that Window.
for(Intersections::iterator i = intr.begin(); i != intr.end(); i++) { for(Intersections::iterator i = intr.begin(); i != intr.end(); i++) {
Window* win = dynamic_cast<Window*>(i->nodePath.back()->getParent(0));
Widget* widget = dynamic_cast<Widget*>(i->drawable.get());
if(!widget) continue;
Window* win = 0;
const osg::NodePath& nodePath = i->nodePath;
for(osg::NodePath::const_reverse_iterator np_itr = nodePath.rbegin(); np_itr != nodePath.rend(); ++np_itr)
{
win = dynamic_cast<Window*>(*np_itr);
if (win) break;
}
// Make sure that our window is valid, and that our pick is within the // Make sure that our window is valid, and that our pick is within the
// "visible area" of the Window. // "visible area" of the Window.
@ -335,9 +345,6 @@ bool WindowManager::pickAtXY(float x, float y, WidgetList& wl)
// If we've found a new Widnow, break out! // If we've found a new Widnow, break out!
else if(activeWin != win) break; else if(activeWin != win) break;
Widget* widget = dynamic_cast<Widget*>(i->drawable.get());
if(!widget) continue;
// We need to return a list of every Widget that was picked, so // We need to return a list of every Widget that was picked, so
// that the handler can operate on it accordingly. // that the handler can operate on it accordingly.