Jump to content
  • Advertisement
Sign in to follow this  
bobbinus

getting text input

This topic is 4796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I want to be create a simple text box for my game menu system that allows the player to input their name, ip address to join a game and type chat messages. What would be a good way to do this? So far I have considered the following... 1) create a directX keyboard input device that will monitor keypressed states. 2) use window messages - WM_KEYDOWN 3) use the GetAsyncKeyState() windows function. 4) use a MFC class text box(not sure whether there is a suitable one for this) Thanking you in advance ;p

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Anon Mike
Text should use WM_CHAR, not WM_KEYxxx.


True, but to support cursor movement with the arrow keys, you still need WM_KEYDOWN.

Share this post


Link to post
Share on other sites
WM_KEYxxx is the (more-or-less) raw unprocessed keystroke event. WM_CHAR messages represent characters (i.e. text) as interpreted by the system. It may take several key strokes to generate a given character depending on your keyboard, locale settings, whether you have an IME present, etc, etc.

Cursor keys do not represent characters, therefore use WM_KEYxxx for them as Dave says. For text use WM_CHAR.

Share this post


Link to post
Share on other sites
you should use windows's IME, which support not only english but also japanese and chinese and...all language that the windows support!however, it is complicated to use IME, IME use message to notify you, the message is
WM_IME_SETCONTEXT:
WM_INPUTLANGCHANGEREQUEST:
WM_INPUTLANGCHANGE:
WM_IME_STARTCOMPOSITION:
WM_IME_ENDCOMPOSITION:
WM_IME_NOTIFY:
WM_IME_COMPOSITION:
you can look up the MSDN for details

Share this post


Link to post
Share on other sites
more or less your going to have to actually draw the box using rectangles
and refreshing the input fields with a char buffer that is updated to reflect the last WM_CHAR/WM_KEYDOWN messages recieved by your winproc

unless ofcourse you want to open a dialog box and minimize the opengl window or close and reopen, may be easier to code but it doesnt look as appealing as the opengl method and you would have to reinstablish all textures and hardware cached verticie arrays

go for the opengl box WM_CHAR/WM_KEYDOWN method


this is a page that explains how to draw fonts in opengl
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=43

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!