soulstorm
16-10-2013 21:26:58
Hello,
I thought that EditBox would work out-of-the box, but it seems it's not automatically adding letters to the caption when pressing any key. Backspace seems to work, though (deleting last character) (why does this work and nothing else?). Note that I am not using any .layout files, I am trying to create everything from code.
I am trying to create my own terminal (little command line). I tried to follow the "Console" example from the library, but it seems I am missing something.
For making the editbox respond to key presses, I have added a delegate
I intend to set the caption here. However, I saw that the MyGUI::KeyCode do not correspond to actual ASCII values, making it difficult to add letters to the edit box using the callback. Is there something I miss, or do I need to implement a gigantic switch statement to capture all possible cases of the KeyCode struct?
EDIT:
I found out that in OIS callback we have to give another argument to the inject() function (the 'text'). This will allow us to get the ASCII code of the key pressed. However, I would still like to know if it was supposed to be done this way (writing with the help of callbacks), or if the it was supposed to work even without callbacks (text insertion - deletion using the keyboard presses)
Can anyone point me to the right direction?
I thought that EditBox would work out-of-the box, but it seems it's not automatically adding letters to the caption when pressing any key. Backspace seems to work, though (deleting last character) (why does this work and nothing else?). Note that I am not using any .layout files, I am trying to create everything from code.
ogrePlatform->initialise(renderWindow, sceneManagerP);
guiRoot->initialise();
MyGUI::Window *consoleWindow = guiRoot->createWidget<MyGUI::Window>("WindowCX", 10, 10, 500, 500, MyGUI::Align::Default, "Main");
consoleWindow->setCaption("Console");
MyGUI::EditBox *editBox = consoleWindow->createWidget<MyGUI::EditBox>("EditBox", 0, consoleWindow->getHeight() - 80, consoleWindow->getWidth(), 40, MyGUI::Align::Bottom, "ConsoleEditBox");
MyGUI::TextBox *textBox = consoleWindow->createWidget<MyGUI::TextBox>("TextBox", 0, 0, consoleWindow->getWidth(), consoleWindow->getHeight() - editBox->getHeight() * 2, MyGUI::Align::Default, "ConsoleTextBox");
textBox->setCaption("this is a caption!");
I am trying to create my own terminal (little command line). I tried to follow the "Console" example from the library, but it seems I am missing something.
For making the editbox respond to key presses, I have added a delegate
editBox->eventKeyButtonPressed += MyGUI::newDelegate(this, &InterfaceComponent::notifyButtonPressed);
void InterfaceComponent::notifyButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char){
//code here...
}
I intend to set the caption here. However, I saw that the MyGUI::KeyCode do not correspond to actual ASCII values, making it difficult to add letters to the edit box using the callback. Is there something I miss, or do I need to implement a gigantic switch statement to capture all possible cases of the KeyCode struct?
EDIT:
I found out that in OIS callback we have to give another argument to the inject() function (the 'text'). This will allow us to get the ASCII code of the key pressed. However, I would still like to know if it was supposed to be done this way (writing with the help of callbacks), or if the it was supposed to work even without callbacks (text insertion - deletion using the keyboard presses)
Can anyone point me to the right direction?