Archived

This topic is now archived and is closed to further replies.

okonomiyaki

How do you handle text boxes?

Recommended Posts

I''ve always wondered this. How do you handle text boxes in a game? Like for a chat window or something. I''m pretty sure you have to make your own, right? Then you''d have to handle the blinking cursor, typing in text and everything yourself. Is there some magic or library that easily handles this?

Share this post


Link to post
Share on other sites
I created a whole window handling routines. Resizing, moving, wordwrap and scrolling.

I also created some custom windows. IE one just to enter commands, one to just display stats, one for continuous text output.

its not that hard. I found the hardest thing was directing the keyboard input and mouse. I''m gonna have to figure out how to swtich between DirectInput and just normal key reading. DirectInput is not good for typing text. At least from what I found when I was doing this. There could be better ways to use directinput to handle that kind of input.





Share this post


Link to post
Share on other sites
I had no problems using DirectInput for my custom GUI controls. I''ve got a working Quake-style console, text boxes, etc.

I have a static array of booleans to store the key press state of each key. I then use a few simple functions to help me process keyboard input and deal with preventing key-repeats. Here''s an example of what I do:
Example:


if ( input_state == INPUT_STATE_GUI )
{
for ( int i = KEY_CODE_START; i < KEY_CODE_END; i++ )
{
if ( IsKeyDown( i ) )
{
if ( !IsKeyHeld( i )
{
m_objGuiManager->ProcessKeyPress( i );
}
}
}
}


Share this post


Link to post
Share on other sites