Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Are you sure?”-box problem

  • “Are you sure?”-box problem

    Posted by Jacob Danell on August 29, 2013 at 11:11 am

    Hi! I’m working with a new script where I really need a “Are you sure?” box so the user won’t do something stupid. The easiest way I found was to make a function with a new UI with the text “Are you sure?” and two buttons, yes and no, because I have to use this multiply times within my script.
    The only problem I have now is how do I get the yes/no information to go out from my function and continue in the previous function that will execute what ever the user now wanted.
    my “Are you sure?” function looks like this atm:

    function areYouSure ()
    {
    var w = new Window("dialog", "Are you sure?", undefined);
    w.orientation = "column";
    var groupOne = w.add("group", undefined, "groupOne");
    groupOne.add("statictext",undefined, "Are you sure?");

    var groupTwo = w.add("group", undefined, "groupTwo");
    var buttonYes = groupTwo.add("button", undefined, "Yes");
    var buttonNo = groupTwo.add("button", undefined, "No");

    buttonYes.onClick = function ()
    {var areYouSureCheck = "yes"; w.hide();}

    buttonNo.onClick = function ()
    {var areYouSureCheck = "no"; w.hide();}

    w.show();
    }

    I know a variables information can’t get out from a function, but I tried anyway and as logic said, it didn’t work.

    Jacob Danell replied 12 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    August 29, 2013 at 2:53 pm

    There is a built-in global function that does this: confirm (message[,noAsDflt,title]); displays a modal window with one question and 2 buttons “Yes” “No”. So unless you want some particular window design it is easier to use confirm.

    message is the message to display, title is the windows title, and noAsDflt sets the default button (the one that is hit if you press enter instead of clicking a button). The default button is normally “YES”, unless you set ‘noAsDflt’ to true.

    if (confirm("Are you sure ?", true, "Please confirm")) doThis()
    else doThat();

    Xavier

  • Jacob Danell

    August 29, 2013 at 3:02 pm

    Perfect! So simple 🙂 Thanks!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy