ComboBox Input

jgillett2

25-11-2012 06:33:48

I love MyGUI and it's whole layout. However, I despise the fact that there isn't much tutorial wise explaining a bit more in depth how to use it. I am having an issue getting my Edit Boxes to accept any text. I click it and I type but nothing will work.


I am injecting all mouse/keyboard events.


void LBind::CreateBindings(Ogre::SceneManager *mSceneMgr, MyGUI::Gui *mGUI)
{

LuaState = luaL_newstate();
luabind::open(LuaState);
MyGUI::EditPtr TB = mGUI->createWidget<MyGUI::Edit>("EditBox",10,10,300, 26,MyGUI::Align::Default,"Main");
TB->setNeedKeyFocus(true);
TB->setProperty("ReadOnly","false");
SceneManager *SMgr = new SceneManager();
SMgr->Manager = mSceneMgr;
SMgr->mGUI = mGUI;
luabind::module(LBind::LuaState) [

luabind::class_<ButtonGui>("ButtonGui")
.def(luabind::constructor<>())
.def("SetText", &ButtonGui::setText)
,
luabind::class_<SceneNode>("SceneNode")
.def(luabind::constructor<>())
.def("CreateNode", &SceneNode::CreateNode)
.def("AttachObject",&SceneNode::AttachObject)
,
luabind::class_<SceneManager>("SManager")
.def(luabind::constructor<>())
.def("CreateEntity", &SceneManager::CreateEntity)
.def("GetRootNode",&SceneManager::GetRootNode)
.def("CreateButton",&SceneManager::CreateButton)
,
luabind::class_<Entity>("Entity")
.def(luabind::constructor<>())
,
luabind::def("Print", Print)


];
luabind::globals(LuaState)["SMgr"] = SMgr;
try {
luaL_dostring(
LuaState,

""//"SMgr:CreateButton('Main',10,10,300, 26)"//"SMgr:GetRootNode():CreateNode():AttachObject(SMgr:CreateEntity(\"Head\",\"ogrehead.mesh\"))"
);
}
catch(const std::exception &TheError) {
std::cerr << TheError.what() << std::endl;
}
}

Altren

26-11-2012 11:40:46

You don't need anything other than createWidget EditBox with default skin to make it accept keyboard input, so your problem not in this code
MyGUI::EditPtr TB = mGUI->createWidget<MyGUI::Edit>("EditBox",10,10,300, 26,MyGUI::Align::Default,"Main"); this should be enough.

1. Does your widget react on mouse input? Does it keep focus after clicking on it?
2. Show me your injectKeyPressed/Released calls.

jgillett2

27-11-2012 21:31:58

It is accepting mouse click and keeping focus. Here are my keyboard injection codes.


bool BaseApplication::mouseMoved( const OIS::MouseEvent &arg )
{
MyGUI::InputManager::getInstance().injectMouseMove(arg.state.X.abs, arg.state.Y.abs, arg.state.Z.abs);
return true;
}

bool BaseApplication::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
MyGUI::InputManager::getInstance().injectMousePress(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id));
return true;
}

bool BaseApplication::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
MyGUI::InputManager::getInstance().injectMouseRelease(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id));
return true;
}

bool BaseApplication::keyPressed( const OIS::KeyEvent &arg )
{
MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(arg.key), arg.text);
return true;
}

bool BaseApplication::keyReleased( const OIS::KeyEvent &arg )
{
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(arg.key));
return true;
}