On Screen Keypad Help

Non-platform specific questions.

On Screen Keypad Help

Postby ganondolf » Mon Feb 22, 2010 6:19 pm

hi,

i am making a game for ppc and want to add a on screen keypad. i have the text box where the name go's (on the pc u would use the keyboard to enter name in the box). i have created separate letters (A-Z, . & backspace).

could anyone provide me with the code so that i i press on a letter (say the "A" letter actor) it inputs the letter in the text input box.

thanks
ganondolf
The only thing for sure is that nothing is for sure
User avatar
ganondolf
 
Posts: 12
Joined: Mon Jan 25, 2010 3:20 pm
Score: 0 Give a positive score

Re: On Screen Keypad Help

Postby skydereign » Mon Feb 22, 2010 9:52 pm

Try this. All this does is add a letter to the text.
Code: Select all
strcat(textactor.text, "a")'
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: On Screen Keypad Help

Postby ganondolf » Tue Feb 23, 2010 1:59 pm

do i put this code in the a letter actor? (mouse button - script editor).
how will it know where to put the text? (i need it in the input text box).
The only thing for sure is that nothing is for sure
User avatar
ganondolf
 
Posts: 12
Joined: Mon Jan 25, 2010 3:20 pm
Score: 0 Give a positive score

Re: On Screen Keypad Help

Postby skydereign » Tue Feb 23, 2010 11:56 pm

It would be on a mouse button down event for 'a', if you look at the code it tells where the text is. The actor is textactor, you would rename it whatever you want.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: On Screen Keypad Help

Postby ganondolf » Thu Feb 25, 2010 1:56 pm

ok, works great. any idea how to make a backspace or clear all text?
The only thing for sure is that nothing is for sure
User avatar
ganondolf
 
Posts: 12
Joined: Mon Jan 25, 2010 3:20 pm
Score: 0 Give a positive score

Re: On Screen Keypad Help

Postby skydereign » Thu Feb 25, 2010 10:30 pm

For a clear text, you can use this.
Code: Select all
strcpy(textactor.text, "\0");


Not sure if this is the best way to do backspace but it was the first thing to come to mind. I am sure you can do it with strncpy among other things, but this will work.
Code: Select all
textactor.text[strlen(textactor.text)-1]='\0';
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: On Screen Keypad Help

Postby ganondolf » Fri Feb 26, 2010 3:58 pm

thanks, the backspace code works great
The only thing for sure is that nothing is for sure
User avatar
ganondolf
 
Posts: 12
Joined: Mon Jan 25, 2010 3:20 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest