Text input - control + left/right

Started by
2 comments, last by Endurion 15 years, 4 months ago
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?
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.
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.
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement