Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS Dialog: Click in second time dialog does not call callback function #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tuanna222
Copy link

fix dialog does not show when using multi native dialog on app.

fix dialog does not show when using multi native dialog on app.
@collingreen collingreen self-assigned this Nov 9, 2014
@collingreen
Copy link
Contributor

This wipes all the dialogCallbacks -- is that the optimal behavior?

Can you put together a repro case for me so I can validate this pull request and merge it in?

@collingreen
Copy link
Contributor

@tuanna222 - can you post an entire Application.js so we can work from exactly the same place?

@tuanna222
Copy link
Author

Application.js

import ui.TextView as TextView;

exports = Class(GC.Application, function () {

  this.initUI = function () {
    var button1 = new TextView({
      superview: this.view,
      text: "button 1",
      color: "white",
      x: 0,
      y: 100,
      width: this.view.style.width,
      height: 100
    });

    button1.on("InputSelect", bind(this,function(){
        var cancel = { label: "Cancel", callback: function () {} };
        var accept = { label: "Accept", callback: function () {
          var ok = { label: "OK", callback: function () {} };
          NATIVE.dialogs.showDialog("accept dialog 1", "accept successfully.", "",[ok]);
        } };
        NATIVE.dialogs.showDialog("In-app purchase", 
          "Are you sure you want to buy ABC package with $1.99 ?", 
          "",
          [cancel, accept]);
    }));

  };

  this.launchUI = function () {};
});

run: devkit debug android
step 1: Click button 1 -> show "In-app purchase" dialog -> click Accept dialog -> show "accept dialog 1" -> this step run correctly
step 2: Click button 1 -> show "In-app purchase" dialog -> click Accept dialog -> dont show "accept dialog 1" -> this step run incorrectly. "accept dialog 1" should be showed.

@collingreen
Copy link
Contributor

Fantastic, thank you. I'll start looking into this today and get back to you as soon as I can.

@collingreen
Copy link
Contributor

It looks like the problem is deeper than this - this example crashes ios completely for me, and the proposed fix doesn't solve the problem on my end either.

This pull request deletes all the existing callbacks after a button is pressed on a dialog, but after the correct callback fires. This feels a bit dodgy, although I suppose the use case assumes you aren't showing more than one dialog at a time.

@mgh - thoughts on this situation?

@tuanna222
Copy link
Author

  1. About crashing on ios, please go to Tealeaf IOS: platform/dialog.mm cause EXC_BAD_ACCESS code=1 exception native-ios#21
    After resolving the crash issue on ios, you still have to edit javascript for above issue.
  2. For above issue, please build on android [devkit debug android] to test.

@collingreen
Copy link
Contributor

@tuanna222 - I see that your change allows the second dialog to fire on android. I added a third nested dialog in the same fashion as a test case and I can't get the third one to open up with your fix applied. Working on that more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants