Skip to content

Commit

Permalink
Moved responsiblity for checking current event focus onto Widget::han…
Browse files Browse the repository at this point in the history
…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
robertosfield committed Aug 1, 2014
1 parent e37838f commit 867d506
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
15 changes: 15 additions & 0 deletions src/osgUI/ComboBox.cpp
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions src/osgUI/LineEdit.cpp
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/osgUI/PushButton.cpp
Expand Up @@ -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;

Expand Down
21 changes: 9 additions & 12 deletions src/osgUI/Widget.cpp
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 867d506

Please sign in to comment.