playMaker

Author Topic: Need help creating custom keyboard [SOLVED]  (Read 7091 times)

cablebob1

  • Playmaker Newbie
  • *
  • Posts: 7
Need help creating custom keyboard [SOLVED]
« on: January 08, 2013, 08:38:39 PM »
I'm building a custom keyboard for my android application. Any ideas how to go about building a string from letter inputs in playmaker?

If this has already been asked, I'm sorry. I've searched for a while now and haven't come across anything. Any help is greatly appreciated. Thanks.
« Last Edit: January 25, 2013, 11:02:18 AM by cablebob1 »

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: Need help creating custom keyboard
« Reply #1 on: January 09, 2013, 02:55:16 AM »
Since its for your android, won't your letters be just a gui element with a location on the screen?  I'de recommend taking a look at the actions under the "device" tab in the playmaker action editor, maybe GetTouchInfo, TouchEvent, or TouchGUIEvent.  Also if you need it, you can convert floats, ints, and bools to strings with the actions listed under the "Convert" tab in the playmaker action editor.  Not sure if this helps you. Good Luck.

cablebob1

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Need help creating custom keyboard
« Reply #2 on: January 09, 2013, 09:42:57 AM »
Yeah, actually building the keyboard is not the problem. I can't figure out how to make a text field that will allow me to type in it. I can press a button (lets say "U"), set a variable equal to U and display that variable via 3Dtext on the screen. Now I press "N" and need to change that variable to U+N. Same with I, T and Y. So, my variable should look something like varU+varN+varI+varT+varY and then my text should read UNITY.

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Need help creating custom keyboard
« Reply #3 on: January 09, 2013, 10:29:44 AM »
I am still new to Playmaker to be honest but I did something similar in Playmaker using the String Builder action and specifying I want only 2 variables involved.

How about creating two variables var1 and var2 and when the keyboard is pressed you add the letter to var1 and then add it into var2 and then when the keyboard is hit again you replace var1 with the new press and then add the new press to var2, it would go like this:
Var1 = ""
Var2 = Var2 + Var1
Player presses the letter "U" you add that to Var1, then add Var1 to the empty Var2 so Var2 is now U. Then when the player presses the letter "N" you replace the U with N in Var1 and then add the N to the U in Var2.

I think it might work am not sure, maybe someone has more knowledge can shed some light on that.

cablebob1

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Need help creating custom keyboard
« Reply #4 on: January 09, 2013, 12:15:02 PM »
Vallar.....You're a genius. Thanks. Got it up and running like you suggested.

Only problem now is backspace. :/ Any Ideas?

Only thing I can think of is:

Set one variable for each letter - lets say max input is 10 characters so you need 10 variables
Have a string builder build a string from all the variables - var1, var2, var3.......var10
Then every time you touch a button you set the next consecutive var and increase an int variable by one
Now for backspace, you would have logic that says: if backspace is pressed, get int value. if int = 1, set var1 equal to nothing. if int = 2, set var equal to nothing.....etc

Hope that makes sense.
« Last Edit: January 09, 2013, 02:16:43 PM by cablebob1 »

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Need help creating custom keyboard
« Reply #5 on: January 11, 2013, 05:43:00 PM »
Ah, glad to see it worked out, congratulations! :D ;D

As for backspace that is a tricky one, not sure if I can manage to get it right for you however, let's take the previous example mentioned with Var1 and Var2 (just so that we are trying to limit the number of variables to a manageable number). I am afraid I couldn't find anything related to arrays or even groups (if it uses a different name) in Playmaker.

What you suggested seems the best yes. Though, you can try something (but I guess this will work perfectly if you are going to only delete the last letter typed); from the previous example, the last letter should be still stored in Var1 even if you have pressed the backspace since from my own understanding that isn't a "letter" it is a bool variable if the player presses it deletes stuff if not, keep going. In which case I would use a "String Contains" action in Playmaker and enter String Variable parameter as Var2 and Contains String parameter as Var1, the event if true would be to alter the String (using String Builder again) and if false would do nothing.

Though I don't believe this will work for more than one letter unless you implement what you mentioned with making 10 variables and limit the characters entered in the text field.

I believe this might be done however in another way, yet it might be a little bit complex. Here is how:

You will need the following variables:
letterEntered (Var1 in previous example) - String Variable
stringTyped (Var2 in previous example) - String Variable
stringLength (new variable) - Int Variable.
lengthToRemove (new variable) - Int Variable.

The scenario would be as follows:
lengthToRemove initialized to 0
1- Player enters letter "U"
2- letterEntered = U
3- stringTyped = U, stringLength = Length of stringTyped = 0
4- Player enters letter "N"
5- letterEntered = N
6- stringTyped = UN, stringLength = Length of stringTyped = 1
7- Player enters letter "I"
8- letterEntered = N
9- stringTyped = UNI, stringLength = Length of stringTyped = 2
10- Player presses Backspace once

The States:

Setup:
In same state as the letterEntered have stringLength increment by 1 and the String Builder do its own normal trick as before (you will just add one more action to increment the stringLength variable).
Create two Events:
1- BackspacePressed
2- FINISHED (default) this is when backspace isn't pressed.

When backspace is pressed which you will test in the state you have the letterEntered change it would trigger BackspacePressed and that would go to a state that will have actions:
1- Subtract from the stringLength 1 (since it was pressed once).
2- Use Get String Left (action in Playmaker) and feed the String Variable parameter stringTyped and the Char Count parameter stringLength.
3- Increment lenghtToRemove by 1 (so when the action is repeated the variable is already incremented to delete the second last letter and so on).

That should get you the required result, when the player/user presses backspace again it should increment lengthToRemove by 1 and from 0 it goes to 1 and so on.


I hope this help.

cablebob1

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Need help creating custom keyboard
« Reply #6 on: January 12, 2013, 07:12:12 PM »
Cool. I think I mostly understood what you were saying.

Is this kinda what you are saying?

Get String Length
Length is "5"
Save this value to Int1
Int1 - 1 = New String Length

So you are pretty much just finding out how long your string is, subtracting 1 and setting your string length to the new value. The only thing I'm not sure of is how to set your string length.........?

This was the idea I came up with yesterday but wasn't sure how to implement the set string length.

Thanks for the help!

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Need help creating custom keyboard
« Reply #7 on: January 13, 2013, 12:21:14 AM »
To set the string length have a state check if the player/user pressed a button and once it presses that button do a Add Int action which will add -1 (which is subtracting) to stringLength variable.

Hope that helps.

Edit: Don't forget to test the variable for its value first so if the stringLength is by whatever logic was set to 0 by mistake the Add Int action won't trigger, if that happens then the string will reverse its display functionality.

So for instance if the player/user didn't type anything and they pressed the backspace make sure it loops back and do nothing; if it goes through normal loop you will find that your stringLength now is -1 and will increase in negative form each time the player/user presses backspace with no text typed. Now if the player/user types anything for real and tries to delete anything, it will do the reverse (displaying the letters he wants to delete rather than the ones he want to keep).
« Last Edit: January 13, 2013, 12:27:01 AM by Vallar »

cablebob1

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Need help creating custom keyboard
« Reply #8 on: January 14, 2013, 04:04:09 PM »
I feel really stupid like I'm missing something that it right in front of my face. Sorry for asking stupid questions but how do you set string length? I understand the math and logic behind it but I don't know how to set string length. I understand getting the string length but I can't figure out how to SET it.... can you do that in Playmaker or do you have to write a script that set's how many characters your string can have?

Sorry for all the trouble. I do appreciate the help though.

Alio

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Need help creating custom keyboard
« Reply #9 on: January 14, 2013, 04:27:26 PM »
Not sure if im on the same page as you guys, but maybe you might have to set up another variable as max string length 10 for example and then do a compare where if its greater than 10 return null or have a font pop up on screen that states something along the lines of "Maximum allowed characters reached" or something like that so that the players know.

If less than or equal to maximum allowed characters return back to state to allow player to enter more characters, if greater than maximum allowed flow to new state that tells them they have reached maximum and have that cycle back to previous state.  this way it will allow them to backspace, re-enter characters, or press key/function to complete input and sent event/message to next state that you intend them to go into.

Hope thats what you were looking for if not im sorry lol.
I just frankenstein it.

cablebob1

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Need help creating custom keyboard
« Reply #10 on: January 14, 2013, 05:20:12 PM »
Thanks Alio. I understand how to limit the max characters.

Get String Length
If String Length is less than 10 allow button to be pressed
If String Length is equal to or greater than 10 do not allow button to be pressed


The problem I'm having is I need to say:

Get String Length
String Length is 10 (var1)
var1 - 1 = 9
Set String length to 9

So I need to take a string that is 10 characters and change it to 9. Then change the 9 characters to 8.....etc

Is there an action that allows you to Set String Length to an Int?

Alio

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Need help creating custom keyboard
« Reply #11 on: January 14, 2013, 05:34:15 PM »
you'll have to use convert int to string/ string to int and create a variable that is a string and one that is an int name it the same and just add suffix _i or _s so you can identify the two quickly by looking at them. Then you jsut need to set your GUI text to that sting and your prob already idenitified your ints so it should solve your prob.

sorry adding something as i might of misread.  once you get the length you want you have to set it and then get it again. otherwise it would loop back over and never replace.  you will have to do this for both the int and the string as they work off of eachother remember, int is your value, string is only displaying that value via gui text
« Last Edit: January 14, 2013, 05:38:09 PM by Alio »
I just frankenstein it.

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Need help creating custom keyboard
« Reply #12 on: January 15, 2013, 01:07:31 AM »
Hello,

That isn't stupid question at all, it took me a while to find.it. to be honest.
Much like what Alio said However to set the variable you use Add Int and that will set the length of the string so it the actions should be like this:

Get String Length (The get action has a parameter for the string to check its length and at the same time storing the length in an int variable of your choice so it works as both getter and setter)
Add Int (stringLength as variable and the Int to add is -1)
Note:the step above will set the string length for you.
Get String Left (feed the stringLength to it and your original string variable)

The above means you will need two different variables one as an int and one as string.

cablebob1

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Need help creating custom keyboard
« Reply #13 on: January 25, 2013, 11:01:43 AM »
THANKS GUYS!!! I finally had time to get back to figuring out the keyboard this morning. I did exactly what y'all said and it works great! I very much appreciate the help.

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Need help creating custom keyboard [SOLVED]
« Reply #14 on: January 25, 2013, 11:06:08 AM »
Awesome, glad you managed to do it! Congratulations! :D