mazoku

Phaser, Cordova and text input on Android

Recommended Posts

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-dialogs/

navigator.notification.prompt

function onPrompt(results) {
    alert("You selected button number " + results.buttonIndex + " and entered " + results.input1);
}

navigator.notification.prompt(
    'Please enter your name',  // message
    onPrompt,                  // callback to invoke
    'Registration',            // title
    ['Ok','Exit'],             // buttonLabels
    'Jane Doe'                 // defaultText
);

 

Share this post


Link to post
Share on other sites

Native dialog sounds fine, although not sure it can accept user input beyond button clicks (maybe it can, example above doesn't show that).

What's wrong with a DOM input field? Pretty sure there are a couple of Phaser Input modules kicking around that fake this in a more Phaser-idiomatic way as well if you wanted to stay within the Canvas and keyboard event listener realm.

Share this post


Link to post
Share on other sites

Are you sure you want the user to choose the file name?

Its not very intuitive on mobile, I don't have any app that makes me choose a file name. They just generate a name for me so I don't have to care.

If you really want to make it, don't forget to validate that the entered input is valid for a file name.

Share this post


Link to post
Share on other sites
1 hour ago, mattstyles said:

Native dialog sounds fine, although not sure it can accept user input beyond button clicks (maybe it can, example above doesn't show that).

What's wrong with a DOM input field? Pretty sure there are a couple of Phaser Input modules kicking around that fake this in a more Phaser-idiomatic way as well if you wanted to stay within the Canvas and keyboard event listener realm.

Yes, it can accept text input. You can also use the native keyboard plugin. Of course, there are multiple ways to do this but that's the Cordova way.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.