mazoku Posted December 13, 2017 Share Posted December 13, 2017 I make a game/app for Android with Phaser that have to save images. The problem is that I want to make the user write the name of the file. What is the best way for this? Quote Link to comment Share on other sites More sharing options...
icp Posted December 13, 2017 Share Posted December 13, 2017 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 ); mazoku 1 Quote Link to comment Share on other sites More sharing options...
mattstyles Posted December 13, 2017 Share Posted December 13, 2017 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. Quote Link to comment Share on other sites More sharing options...
bruno_ Posted December 13, 2017 Share Posted December 13, 2017 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. mattstyles 1 Quote Link to comment Share on other sites More sharing options...
icp Posted December 14, 2017 Share Posted December 14, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.