Permalink
Browse files

Moved responsiblity for checking current event focus onto Widget::han…

…dleImplementations().

Added support for closing CombinBox popup when the mouse is clicked outside the popup or combobox widget.


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14396 16af8721-9629-0410-8352-f15c8da7e697
  • Loading branch information...
osg-training-guest committed Aug 1, 2014
1 parent e37838f commit 867d506cf1b2c3d2a4925e44502e01a4d0b0228c
Showing with 28 additions and 12 deletions.
  1. +15 −0 src/osgUI/ComboBox.cpp
  2. +2 −0 src/osgUI/LineEdit.cpp
  3. +2 −0 src/osgUI/PushButton.cpp
  4. +9 −12 src/osgUI/Widget.cpp
View
@@ -40,6 +40,17 @@ bool ComboBox::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event
osgGA::GUIEventAdapter* ea = event->asGUIEventAdapter();
if (!ea) return false;
+ if (!getHasEventFocus())
+ {
+ if (ea->getEventType()==osgGA::GUIEventAdapter::PUSH && _popup->getVisible())
+ {
+ _popup->setVisible(false);
+ }
+
+ return false;
+ }
+
+
switch(ea->getEventType())
{
case(osgGA::GUIEventAdapter::SCROLL):
@@ -126,6 +137,10 @@ bool ComboBox::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event
_popup->setVisible(false);
}
}
+ else
+ {
+ _popup->setVisible(false);
+ }
break;
}
case(osgGA::GUIEventAdapter::RELEASE):
View
@@ -32,6 +32,8 @@ LineEdit::LineEdit(const osgUI::LineEdit& label, const osg::CopyOp& copyop):
bool LineEdit::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event)
{
+ if (!getHasEventFocus()) return false;
+
osgGA::GUIEventAdapter* ea = event->asGUIEventAdapter();
if (!ea) return false;
View
@@ -32,6 +32,8 @@ PushButton::PushButton(const osgUI::PushButton& pb, const osg::CopyOp& copyop):
bool PushButton::handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event)
{
+ if (!getHasEventFocus()) return false;
+
osgGA::GUIEventAdapter* ea = event->asGUIEventAdapter();
if (!ea) return false;
View
@@ -212,20 +212,17 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
// OSG_NOTICE<<"EventTraversal getHasEventFocus()="<<getHasEventFocus()<<std::endl;
- if (getHasEventFocus())
- {
- // signify that event has been taken by widget with focus
- ev->setEventHandled(true);
+ // signify that event has been taken by widget with focus
- osgGA::EventQueue::Events& events = ev->getEvents();
- for(osgGA::EventQueue::Events::iterator itr = events.begin();
- itr != events.end();
- ++itr)
+ osgGA::EventQueue::Events& events = ev->getEvents();
+ for(osgGA::EventQueue::Events::iterator itr = events.begin();
+ itr != events.end();
+ ++itr)
+ {
+ if (handle(ev, itr->get()))
{
- if (handle(ev, itr->get()))
- {
- (*itr)->setHandled(true);
- }
+ (*itr)->setHandled(true);
+ ev->setEventHandled(true);
}
}

0 comments on commit 867d506

Please sign in to comment.