osgWidget.Input是OpenSceneGraph的一种小部件(widget),用于创建带有可编辑文本输入框的用户界面。
osg::ref_ptr<osgWidget::Input> input = new osgWidget::Input("input1", "Hello World!", 200, 50);
input->setLocation(osgWidget::Widget::BOTTOM_CENTER);
input->setFont("fonts/arial.ttf");
Input(const std::string& text = "", const float& width = 100.0f, const float& height = 30.0f,
const osgWidget::Input::InputMask& mask = osgWidget::Input::IM_ASCII, const osgWidget::Input::InputType& type = osgWidget::Input::IT_DEFAULT);
void setText(const std::string& text);
设置文本输入框中的文本。
std::string getText();
获取文本输入框中的文本。
void setEditable(const bool& editable);
设置文本输入框是否可编辑,默认为可编辑状态。
bool isEditable() const;
获取文本输入框是否可编辑。
void setCursorPosition(const unsigned int& pos);
设置文本输入框中光标的位置。
unsigned int getCursorPosition() const;
获取文本输入框中光标的位置。
void setFont(const std::string& fontfile);
设置文本输入框中文本的字体。
void setTextColor(const osg::Vec4& color);
设置文本输入框中文本的颜色。
void setBackgroundColor(const osg::Vec4& color);
设置文本输入框的背景颜色。
void setBorderColor(const osg::Vec4& color);
设置文本输入框的边框颜色。
void setBorderWidth(const float& width);
设置文本输入框的边框宽度。
virtual void resize();
重设文本输入框的尺寸。
virtual const char* getNodeType() const;
获取节点类型。
本文介绍了osgWidget.Input的构造函数和常用方法及其作用,希望对您的OpenSceneGraph开发工作有所帮助。