Help ! Z.Prompt Problems


#1

Hi,

I am making one experience with the use of Z.Prompt to require the name of the user I am encountering the following problems :

  • Z.Prompt don’t work on Windows Preview, simply don’t appear any box and execution stops.
  • On Android the popup requesting text appears but if we tap anywhere out of the popup it disappears and the execution stops. I have checked the “done” and “cancel” event on the exit from the popup after the show() but nothing seems to change.
  • To avoid the problem I have create a variable to check the void insertion of data and make the popup reappear but it’s silly because that generate errors on execution time…

The code :

myname = Z.Prompt({
  title: "Leaderboard",
  text: "Insert your name:",
  defaultValue: "test",
  maxLength: 8,
  filterProfanity: true
});

myname.on(“confirm”, function(nickname : string) {

console.log("They entered: " + nickname);
lastnicknameinserted = nickname; 

    };

Really simple but don’t work.

I hope someone will point me in the right direction or give some hint.


#2

Hi there,

Just to clarify a few things:

  1. The Zappar in Windows preview option is not a full version of the app. Some functionality will only work on mobile platforms, Z.Prompt being one of these, as it’s designed to bring up the mobile device’s native prompt window.

  2. The cancel event is fired when the user taps on the ‘Cancel’ option. Tapping outside of the popup to cancel the input (and close the window) won’t trigger the event. You can use the .on("done") event handler for this, which will return null if the input was cancelled.

prompt.zpp (187.1 KB)

I’ve uploaded a basic zpp which shows a Z.Prompt() in action.

Previewing the project will display a plane which launches a prompt when tapped.

The user input is stored using theirName, which is then used as the argument in the text0 node’s text(...) setter function, which will update the text on the screen.

Feel free to have a look and experiment with it, and please let me know if you have any questions.

All the best,
Seb


#3

The cancel event is fired when the user taps on the ‘Cancel’ option. Tapping outside of the popup to cancel the input (and close the window) won’t trigger the event. You can use the .on(“done”) event handler for this, which will return null if the input was cancelled.

That will only generate more problems, the .on(“done”) is called every time so this enters in a loop of popoup without any exit.

I have modified the code in your example to make an example.

I have added that code :

myname.on("done", dialogDone);

function dialogDone(t){
    if (t === null){
        //code to run if the dialogue returned null as a result of it being cancelled
         myname.show();
    }
}

This seems a solution to make the popup reappears but… try…

This is the project with the code…
prompt.zpp (190.4 KB)


#4

The only solution I have found is using .one(“done”) instead of .on(“done”), this avoid the problem of the unwanted loop but don’t seem the right solution.

myname.one(“done”, dialogDone);

function dialogDone(t){
if (t === null){
//code to run if the dialogue returned null as a result of it being cancelled
myname.show();
}
}