playMaker

Author Topic: Open IOS keyboard[SOLVED]  (Read 15028 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14400
  • Official Playmaker Support
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #15 on: February 10, 2014, 01:19:48 AM »
Hi,

 try this:

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved.
// __ECO__ __ACTION__

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Device)]
[Tooltip("Opens the native keyboard provided by OS on the screen")]
public class OpenDeviceKeyBoard : FsmStateAction
{
#if UNITY_IPHONE
[Tooltip("The KeyBoard type")]
public TouchScreenKeyboardType keyBoardType;
[Tooltip("AutoCorrection setting")]
public FsmBool autoCorrection;
[Tooltip("single or multiline setting")]
public FsmBool multiLine;
[Tooltip("Hides inputed text")]
public FsmBool secure;
[Tooltip("Swith to Alert keyboard theme")]
public FsmBool alert;
[Tooltip("The placeholder text")]
public FsmString textPlaceHolder;


[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The text the user is entering")]
public FsmString text;

[Tooltip("Event sent when keyboard becomes active. Comes back to the state to keep using the keyboard")]
public FsmEvent active;

[Tooltip("Event sent when the user is done")]
public FsmEvent done;


private static TouchScreenKeyboard keyboard;


private bool _active = false;
private bool _done = false;

public override void Reset()
{
_active = false;
_done = false;
keyBoardType = TouchScreenKeyboardType.Default;
autoCorrection = true;
multiLine = false;
secure = false;
alert = false;
textPlaceHolder = "";
}

public override void OnEnter()
{
_done = false;

UnityEngine.Debug.Log("OpenDeviceKeyBoard OPEN");
if (keyboard == null)
{
keyboard = TouchScreenKeyboard.Open(text.Value,keyBoardType,autoCorrection.Value,multiLine.Value,secure.Value,alert.Value,textPlaceHolder.Value);


}else{
UnityEngine.Debug.Log("OpenDeviceKeyBoard OPEN NOT NULL");
}
}

public override void OnUpdate()
{
if (keyboard != null)
{
text.Value = keyboard.text;


if (!_active && keyboard.active)
{
_active = true;
Fsm.Event(active);
}

if (!_done && keyboard.done)
{
keyboard = null;
_done = true;
UnityEngine.Debug.Log("OpenDeviceKeyBoard DONE");
Fsm.Event(done);
Finish();
}

}
}
#endif
}
}

bye,

 Jean
« Last Edit: May 09, 2014, 01:29:33 AM by jeanfabre »

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #16 on: May 08, 2014, 10:51:02 AM »
Sorry, but I seem to be having the same issue. This is on iPod 5, ios 7.

I did the same as the others:
-Created a state with a gui button that calls the "Show Keyboard" state.
-The Show Keyboard state has the OpenDeviceKeyboard action.
-"Done" triggers the Finished event that goes back to the first state.

First time through everything works fine, but after clicking done on the keyboard, it goes back to the first state, but the second time through, the keyboard never appears.

I added a button and other diagnostics to the second state, so I know the wiring is working fine, there is just no keyboard. I am NOT doing anything with the "Active" section of the keyboard, as previously suggested.

Anyone else actually getting this to work?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14400
  • Official Playmaker Support
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #17 on: May 09, 2014, 01:16:06 AM »
Hi,

 testing and it's really weird, it seems the second time doesn't register. I am trying to mess around with it to no availability.

So indeed, there is something not working properly, but I can't nail exactly what and why...

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14400
  • Official Playmaker Support
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #18 on: May 09, 2014, 01:30:59 AM »
Hi,

 ok, found the issue ( internal flag not being reset properly).

 please download the new file from this location now ( will be served by the upcoming ecosystem browser).

https://github.com/jeanfabre/PlayMakerCustomActions_U3/blob/cd769d34222b8aca2515531c132a407162b90e26/Assets/PlayMaker%20Custom%20Actions/Device/OpenDeviceKeyBoard.cs

bye,

 Jean

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #19 on: May 09, 2014, 09:03:25 AM »
Perfect. Works just fine now.

As always, thanks for the amazingly fast fix ;D

And not to get greedy, but now that it's working, would it be possible to have an option so that when it opens again, the text field could be reset to blank instead of retaining the previous entry?

I don't know if that's even possible since it's Apple's built-in keyboard, but if not, does anyone know of the series of actions I would use to clear that field after I store it's contents in a variable. I'm doing kind of a data entry app, and having to hit that little "x" in the field for hundreds of consecutive entries will get rather tedious.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14400
  • Official Playmaker Support
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #20 on: May 13, 2014, 04:39:14 AM »
Hi,

it uses the content of the "text" variable you use. so you need to use "set string value" and set that variable to an empty string and then open the keyboard.

 Have you tried that already?

bye,

 Jean

keziahwen

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #21 on: December 13, 2014, 11:11:25 PM »
Hi Jean,

I have a problem getting updated value from the "text"
basically, i have two buttons doing math, one is subtotal, and the other one is total. so when the player enter value in "subtotal", the "total" button value should be changed according to the entry.
so when the first time i open the keyboard and type the value in subtotal, it all shows fine -- value display on both "subtotal" and "total"
however, when i click on the subtotal again to modify the value, it only shows fine on the "subtotal" but not the "total" (total still showing the previous value).

can you help?
ps i updated the cs file you attached before, still not working..

thanks

keziahwen

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Open IOS keyboard[SOLVED]
« Reply #22 on: December 14, 2014, 01:43:38 AM »
Hi all again,

i sort it out already.....
i add another line of code to reset the text value so whenever you click the button again, the value will be reset.

cheers

joel.carlson

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
    • Salvation's Story
Re: Open IOS keyboard[SOLVED]
« Reply #23 on: March 12, 2015, 03:24:25 PM »
Is this action still working? I'm trying it on my Android build and nothing is coming up when I add it to my state.
Check out Noah's Elephant in the Room, Bible ABCs for Kids, Bible Coloring for Kids, and Noah's Bunny Problem at
Salvations Story