Jump to content
  • Advertisement
Sign in to follow this  
Acticore

Unity Windows programming question.

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

Hi, I've got a question on keyboard input for dialog boxes, and I'd appreciate it very much if someone would be nice enough to help me out. I'm trying to make a simple calculator program that has 10 number buttons (0-9), four operator buttons (+, -, *, and /), an equals button, a clear button, and an edit box to display everything. I have the application fully functioning with the buttons. What I'm trying to do is to allow the user to use the number pad as an alternative input over the buttons. I can get keyboard input for a normal window fine, but a dialog box is limited to a specific range of keyboard inputs, and as far as I'm aware, ignores everything else. How can I get the dialog box to recognize input from the number pad? I was able to have the main (temporarily unhidden) window catch the input and then pass it to the dialog box, but the only way that works is if the user switches to the main window for inputting numbers, and then switches back to the calculator dialog box to see what was input. Once the application is completed, the main window will be hidden, and this won't be possible (it's also not practical). I'm required to set this up as a dialog box. I could probably figure this out on my own if I kept going at it for a few more hours, but I've been searching for a while, so I figured asking the GameDev community might get me a more helpful response. Thanks for your time.

Share this post


Link to post
Share on other sites
Advertisement
What programming language are you using, and how are you setting up the dialog box?
Normally in a dialog-resource, you can set a hot-key for each button by using an '&' character before the letter corresponding to the hot-key. So if you name your buttons "&0", "&1", etc.. the number keys should be hot-keys for the buttons. The '&' will be invisible.

Share this post


Link to post
Share on other sites
You can try subclassing the dialog and answering the WM_GETDLGCODE message with DLGC_WANTALLKEYS.

If you're using MFC it's as simple as adding:

ON_WM_GETDLGCODE()

to the message map, and then adding this method:

UINT CMyDialog::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}

But you have to remember that navigational keys (arrows, TAB) could still pose problems.

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!