Page 1 of 1

On Screen Keypad Help

PostPosted: Mon Feb 22, 2010 6:19 pm
by ganondolf
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

Re: On Screen Keypad Help

PostPosted: Mon Feb 22, 2010 9:52 pm
by skydereign
Try this. All this does is add a letter to the text.
Code: Select all
strcat(textactor.text, "a")'

Re: On Screen Keypad Help

PostPosted: Tue Feb 23, 2010 1:59 pm
by ganondolf
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).

Re: On Screen Keypad Help

PostPosted: Tue Feb 23, 2010 11:56 pm
by skydereign
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.

Re: On Screen Keypad Help

PostPosted: Thu Feb 25, 2010 1:56 pm
by ganondolf
ok, works great. any idea how to make a backspace or clear all text?

Re: On Screen Keypad Help

PostPosted: Thu Feb 25, 2010 10:30 pm
by skydereign
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';

Re: On Screen Keypad Help

PostPosted: Fri Feb 26, 2010 3:58 pm
by ganondolf
thanks, the backspace code works great