#### Archived

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

# How do you handle text boxes?

## Recommended Posts

okonomiyaki    548
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 on other sites
okonomiyaki    548
Ok, that''s weird, I just noticed 2 other threads on pretty much the exact same topic. I think I got it, thanks.

##### Share on other sites
Jenison    216
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 on other sites
Expendable    126
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 );      }    }  }}