how can i hide the inputfield at the console widget?


05-12-2007 18:51:02


right now i have successfully migrated to version 097.
I use the console widget for some output from my server. As you can see on the screen, there is an input field under the console, nearby the cursor.
the question is why? i tried to hide it with ->hideInputBox().

Is there a better widget to use for multilining?


05-12-2007 18:55:56

Even if you hide the InputBox, I don't think the List would expand to fill that space. I'd have to look at the code to be sure. The LabelArea widget best fits your needs here. Now that I think about it, a few of the Console features should be added to the LabelArea widget, like setMaxLines functionality.

Nice screenshot! :)


05-12-2007 19:07:11

thx for the fast replay... much better support than some of the comercial libs and products :)

Ill look at the LabelArea.... if it works like a multiline textbox ill be happy with it :)


05-12-2007 19:25:03

The LabelArea is pretty much read only, the user can't interact with the text. The "TextArea" widget will be the equivalent of the MultiLine TextBox, but its not implemented yet. It actually wouldn't be a lot of effort to create, its essentially a List of TextBoxes that are not read only. Although I'd want to polish it to support Ctrl+Page Up/Down, and I'd have to implement highlighting across rows.


05-12-2007 19:35:44

sounds good with the text area. in the past i ve implemented multilining in a similiar way. i just created a bunch of textboxes.

to the LabelArea... how can i write more than 1 row? do i have to adjust it with the vertical alignment?


05-12-2007 19:47:21

Ah! I just looked at the code, and realized that LabelArea won't work, since it's meant to be used with "setText", where you know the entire caption of the widget before hand. So what we really need is for the Console to have the InputBox hidden, and List extended to full view.

How does this sound: I'll make a function Console::setReadOnly(bool), along with a getter. When set to true, the InputBox is hidden, and the list is expanded. Otherwise its visible and list ends at input box beginning.

Sorry about suggesting the LabelArea widget, the functionality we want is already a part of the console widget, but we want output only. (am I right on this?)


05-12-2007 20:37:29

yes! youre right... only output.
and yes this sounds great with the setReadOnly(bool) it will fit my needs very well...


06-12-2007 21:09:45

Hi kungfoomasta,

i think there is a problem with the event EVT_MOUSE_ENTER / LEAVE on the console.

Here is the code how ive added the handlers. they worked on my textboxes very well

m_pGUI_ChatBox = m_pGUI_SHEET->createConsole();
m_pGUI_ChatBox->setDimensions( m_rSize);
m_pGUI_ChatBox->addEventHandler( Widget::EVENT_MOUSE_ENTER, &CGW_CHAT::EVT_MOUSE_ENTERED_WIDGET, this );
m_pGUI_ChatBox->addEventHandler( Widget::EVENT_MOUSE_LEAVE, &CGW_CHAT::EVT_MOUSE_LEFT_WIDGET, this );

but the events are not fired by the console widget...


06-12-2007 22:24:25

Oh! Thanks for bringing this forward, I can see how this can occur. Since the console is a composition widget, its made of scroll bars, text box, list, etc. The actual Console is the background image, which is covered by all other widgets. So I need to call setPropogateEvents(ENTER/LEAVE,true) for all component widgets.

I will add this in tonight along with the setReadOnly functionality, so that I don't forget about it.


06-12-2007 22:34:13

cool :) very good...

another question....
Is there a way to set the textcolor for every single line and not for all together?


06-12-2007 23:14:52

The code is implemented to change every character uniquely, but I haven't made any public interface. I could probably add the following:


which would change the whole text. Any suggestions regarding interface for coloring by line? Or by character even? Or by word?

Here are some ideas..

// sets matching characters a certain color
Label::setCharacterColor(Ogre::UTFString::code_point cp, Ogre::ColourValue c);
// sets all matching text to color c
Label::setTextColor(Ogre::String text, Ogre::ColourValue c);

LabelArea::setCharacterColor(unsigned int line, Ogre::UTFString::code_point cp, Ogre::ColourValue c);
// sets a line of text to a certain color
LabelArea::setTextColor(unsigned int line, Ogre::ColourValue c);
LabelArea::setTextColor(unsigned int line, Ogre::String text, Ogre::ColourValue c);

Label derives to TextBox
LabelArea derives to Console, and probably TextArea.

You might need to remind me about this, the Text implementation may change a little due to the other big changes I'm working on.


07-12-2007 08:52:15

I fixed hideInputBox, I don't need the setReadOnly bit. I've been out of it lately..


08-12-2007 20:36:45

this sounds like a good implementation. for me i only need the setTestColor(lin, CV) (it is a chat widget in my game)

hmmm i think the word coloring is usefull for the multiline widget. if you will implement a small parser for text like this way it will help a lot.

set some variables as predefined colors.
Lable:setPreDefColor(Ogre::String text, Ogre::ColourValue c);
Usage: MyText->setPreDefColor( "red", cvRED );
then the widget is coloring all words betwen /red \red in this text:

My new car has /red this \red color.

than the word 'this' is colored in cvRED.

but there are some tasks to do for this and at the moment it is only a nice to have :)


08-12-2007 21:04:54

Awesome, that is a good idea!

I'm currently trying to get the render portion rolling, I've been lazy to dive in and do it. I've never forgotten about text coloring, but haven't been able to get around to implementing it, like a lot of other things. I'll refer back to this thread when the time comes. Do you have any deadline regarding this?


08-12-2007 22:38:52

no there is no deadline... but think of all the quests and hints and so on in the games... i allways code this things by my self in the past and if qgui supports this, i think you got a unique feature :D


08-12-2007 23:37:21

another question... :)

how can i set the text in the console direct?
I know that there must be a lablearea... but how can i set the text in this widget directly?

if i use setText() i set the text in the input box but this is not useful for me.

An other question.
how can i block the input from input field so that i can preprocess the input.

the usecase is:
a chat window where the input is sent to the server and is received via a chatmessage and is then displayed in the labelarea.

therefore i need to block the input and set the text directly :)


09-12-2007 07:43:49

I think the function is "addText" to add text directly.

An other question.
how can i block the input from input field so that i can preprocess the input.

Good question. :lol:

I haven't implemented this, but here is my idea:

I will make a function:

Console::setInputValidator(InputValidator* v);

An InputValidator is any class with some method that returns true or false. If true is returned, the text is output to the console. If false is returned, the text is not output to console. If no validator is set, the text is always output to the console. This way you could process the input as you want and send it directly, or choose not to send it directly to console output, and do whatever you want with it.



09-12-2007 09:52:55

addText... hmm i don't know why i didn't recognized it... :oops:

The idea with the InputValidator sounds realy good and i will use ist.
i think for many cases it is enough if i can set a flag to block the text from input only.
So the flow of the program will be
Create widget:
Console* pCon = pSheet->createConsole();
pCon->setBlockInput( true );

on Event:
string strText = pCon->getText();

modify the string like wanted.
pCon->addText( strText );


09-12-2007 11:27:42

Awesome, your method is easier and will work. I want to use my input validator idea for text boxes at some point. I remember my editor I made in MSVC++, and it would have been sweet to have text boxes that only accepted integers, or integers/minus/decimal, etc. Plus the Validator can be re-used for any text boxes you want.

I'll use your setBlockInput/getBlockInput functions for console, and save my idea for later. :)

I can't commit this right now, my code is not useable, since the render changes are being made..


14-12-2007 02:40:18

I have added the following functions into my code base:

Console::setBlockInput(bool );

You won't see them until the next commit, but that should be soon. :)


14-12-2007 18:06:32


very cool... i am downloading the new rev288 :D

Thanks for the very cool support and fast response :)


15-12-2007 12:59:30

Hi kungfoomasta,

the blocking works very good. but i had to implement another function to get the intput text.

in quickguiconsole.h i added getTextFromInput()

void addText(const Ogre::UTFString& text);

Ogre::String getTextFromInput();

void clearInput();

and here is the function (very simple :) ) from the .cpp

// ------------------------------------------------------------------------
// getTextFromInput()
// get the input from the input field
// ------------------------------------------------------------------------
Ogre::String Console::getTextFromInput()
// return the text
return mInputBox->getText();

i think this is the easiest way to get the inputfield from the console.
now the flow is:

// Get the nick
string strText = m_pMessenger->GetUserNickname();

strText += " > ";

// Get the text
strText += m_pGUI_ChatBox->getTextFromInput();

// clear the text


15-12-2007 22:25:41

I have committed the function, thanks for the suggestion!

These are the functions, I renamed for consistency:



16-12-2007 12:37:43

perfect :)