[solved] Console InputHandler problem


03-01-2009 15:36:54


i am using QuickGUI 8.12 with Ogre 1.6 and got a problem when registering a console input handler via setConsoleInputHandler(). I am not sure if my usage of the console widget is correct:

m_conMain->setConsoleInputHandler<myClass>(&myClass::onConsoleInput, this);

bool myClass::onConsoleInput(QuickGUI::Console* console, bool& clearInputBox, bool& addToDisplayArea) {
clearInputBox = true;
addToDisplayArea = true;

return true;

One problem is that i cannot compile this code unless i change the QuickGUI file "QuickGUIConsole.h".
Unchanged version:

template<typename T> void setConsoleInputHandler(void (T::*ConsoleInputHandler)(Console* console, bool& clearInputBox, bool& addToDisplayArea), T* obj)

Changed version (first parameter: changed the void to bool in the method signature):

template<typename T> void setConsoleInputHandler(bool(T::*ConsoleInputHandler)(Console* console, bool& clearInputBox, bool& addToDisplayArea), T* obj)

The changed version of the code compiles and executes. But now the console acts unexpected if i enter a Text and hit return. The text is moved to the text area as expected, but the textbox is filled (24 times) with the last character that i have entered. If i remove the call to setConsoleInputHandler() the console widget works as expected.

Thanks in advance :)


03-01-2009 16:04:39

Oops, there was a typo in QuickGUIConsoleInputHandler.h, requiring the return type to be bool. I've changed this to void. Regarding the textBox being filled up, I will look into this, have to run some errands first.


03-01-2009 17:55:35

I modified the QuickGUIConsoleInputHandler.h file, and tested my own function, seems to work fine.

void MainForm::testConsoleHandler(QuickGUI::Console* c, bool& clearInputBox, bool& addToDisplayArea)
clearInputBox = false;
addToDisplayArea = true;

cd->console_inputBoxDefaultFontName = "micross.16";
cd->widget_dimensions = QuickGUI::Rect(300,300,200,200);
QuickGUI::Console* console = mGUIManager->getActiveSheet()->createConsole(cd);

Keep in mind if you hit a breakpoint after pressing down a button, the button down event from OIS will keep registering, which can result in repeated input.


03-01-2009 18:49:34

I was not aware of this OIS behaviour when hitting a breakoint. I have changed the header files and everything works fine.

Thank you for your efforts!


04-01-2009 00:07:49

Glad to be of help. :) I've re-uploaded 8.12 with the minor fix, as well as an important fix related to GUI rendering and using shadows. I've also added in the ability to add an event handler for characters when input into the console InputBox. This, combined with setting the input box text, should allow features such as changing text color after typing keywords.