Jump to content
  • Advertisement
Sign in to follow this  
EmpyrealHell

Text input - control + left/right

This topic is 3613 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

Ok, so I've written some code for keyboard input and I've got it broken down into three basic parts: The directinput code for in-game stuff, using the WM_KEYDOWN/WM_KEYUP message for menus and WM_CHAR/WM_KEYDOWN for text input. The first two parts work fine, however I'm running into some issues with the text input. By using the WM_CHAR message I have IME input working, basic text input works just fine, but I noticed that it doesn't handle a cursor in the input, so I set about to recreate the basics of text input that present day users are used to; home/end keys, shift to select blocks of text, etc. After all of that was ironed out I'm left with one last hurdle: the control + left/right key function. I can't think of a way to reproduce this without using a regular expression and I really don't want to have to add all of that code for one single function, so I thought I'd present the question here. Is there a way to make windows handle the cursor and all of that for me without using a windows control (so that I can put my own graphics around it), or is there an easier way to add the control functionality without using a regular expression?

Share this post


Link to post
Share on other sites
Advertisement
Consider using Direct Input to read keyboard data back. This is pretty much exclusively how we handle input at our studio, it may not work well with your IME stuff that you are doing, but it may be possible to still read WM_CHAR events for text input when required and use Direct Input to handle non text based input like CTRL + any button.

Share this post


Link to post
Share on other sites
Quote:
Original post by cmroche
Consider using Direct Input to read keyboard data back. This is pretty much exclusively how we handle input at our studio, it may not work well with your IME stuff that you are doing, but it may be possible to still read WM_CHAR events for text input when required and use Direct Input to handle non text based input like CTRL + any button.


Hmm, ok, let me clarify a little bit. I can detect the event just fine, I know when a control + arrow key happens. The issue is that in order to make the cursor go where it should, I would need to use a regular expression (I was thinking something along the lines of go to the next instance of [^a-zA-z0-9][a-zA-z0-9], it's not exact but it seems to get a pretty close emulation). I don't want to have to add in a regular expression library to the mix if I can avoid it, since there's not really anything else I would need it for in this project.

Share this post


Link to post
Share on other sites
Are you sure you'd need regex for that? Just check for any letters/numbers with a simple if, no overblown regex needed. You may just need to take in account a lot of foreign characters.

Depending on if you're using Ascii or Unicode this will be different.

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!