Announcement

Collapse
No announcement yet.

UDK text input using the native iOS keyboard

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    UDK text input using the native iOS keyboard

    It's easy to use the native iOS keyboard to get the text input from player in UDK despite it's undocumented function. I've prepared an extended example below.

    Code:
    /** Used to set the callback on keyboard dialog close */
    delegate KeyboardInputFunction(optional String TextInput);
    
    /**
     * Launches saved callback function (we can't pass delegates directly) 
     */
    exec function ProcessKeyboardInput()
    {
    	KeyboardInputFunction();
    }
    
    /** 
     * Keyboard call interface: opens native iOS keyboard to receive user's text input
     *
     * @param 	Title 			Dialog title
     * @param 	DefaultText 	Default text input value
     * @param 	InputFuntion 	Function to be called on dialog close (callback)
     */
    function MobileOpenKeyboard(String Title, String DefaultText, delegate<KeyboardInputFunction> InputFuntion)
    {
    	KeyboardInputFunction = InputFuntion;
    	ConsoleCommand("mobile getuserinput \""$Title$"\" \""$DefaultText$"\" \""$nameof(ProcessKeyboardInput)$"\"");
    }
    
    /**
     * EXAMPLE: HOW TO USE
     */
    exec function SomeBtnPressed()
    {
    	MobileOpenKeyboard("Please enter your name", "Tought Guy", SetPlayerName);
    }
    
    /**
     * EXAMPLE: CALLBACK FUNCTION
     */
    function SetPlayerName(optional string TextInput)
    {
    	`log("New player name is:" @ TextInput);
    }
    The result you can see here:

    [screenshot]http://2.bp.blogspot.com/-nyTXTG4IHMs/Utse48GwVMI/AAAAAAAAAzU/BkcPujlVSPk/s1600/udk_ios_keyboard.jpg[/screenshot]
Working...
X