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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.