Added support for ComboBox::currentIndexChanged*(uint) callback API.

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14409 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-08-14 19:00:37 +00:00
parent 5f74fdc326
commit f28d460caa
3 changed files with 68 additions and 15 deletions

View File

@@ -4,12 +4,35 @@
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
struct ComboBoxCurrentIndexChangedImplementation : public osgDB::MethodObject
{
virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
{
if (inputParameters.empty()) return false;
osg::Object* indexObject = inputParameters[0].get();
unsigned int index = 0;
osg::DoubleValueObject* dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject);
if (dvo) index = static_cast<unsigned int>(dvo->getValue());
else
{
osg::UIntValueObject* uivo = dynamic_cast<osg::UIntValueObject*>(indexObject);
if (uivo) index = uivo->getValue();
}
osgUI::ComboBox* cb = reinterpret_cast<osgUI::ComboBox*>(objectPtr);
cb->currentIndexChangedImplementation(index);
return true;
}
};
REGISTER_OBJECT_WRAPPER( ComboBox,
new osgUI::ComboBox,
osgUI::ComboBox,
"osg::Object osg::Node osg::Group osgUI::Widget osgUI::ComboBox" )
{
ADD_UINT_SERIALIZER(CurrentItem, 0);
ADD_UINT_SERIALIZER(CurrentIndex, 0);
ADD_VECTOR_SERIALIZER( Items, osgUI::ComboBox::Items, osgDB::BaseSerializer::RW_OBJECT, 0 );
ADD_METHOD_OBJECT( "currentIndexChangedImplementation", ComboBoxCurrentIndexChangedImplementation );
}