Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Use xfa.host.beep to trigger two consecutive beeps?

Brian3_14
Level 3
Level 3

Seems like this should be pretty straight forward but apparently not.

I've tried various combinations, placing xfa.host.beep(1) in:

- consecutively in the click event of button;

- separately in the mouseUp and click event;

- placing xfa.host.beep into a function and calling the function twice

- calling the function then xfa.host.beep(1);

Even tried xfa.host.beep(1) in the click event of Button1 and then executing the click event of hidden Button 2, which contained xfa.host.beep(1).

Any work around suggestions? Thanks!

Brian

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi Brian,

Try this;

xfa.host.beep(1)

app.setTimeOut("xfa.host.beep(1)",500);

   

Which calls the beep, then half a second (or 500 m/s) later calls it again.

Regards

Bruce

View solution in original post

4 Replies
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi Brian,

Try this;

xfa.host.beep(1)

app.setTimeOut("xfa.host.beep(1)",500);

   

Which calls the beep, then half a second (or 500 m/s) later calls it again.

Regards

Bruce

View solution in original post

Brian3_14
Level 3
Level 3

Bruce -

Thanks for the great response; works perfectly.

As a follow-up, could xfa.host.beep(1) be placed within the code for a custom dialog? So rather than calling the beep first, then triggering the dialog box, just place xfa.host.beep(1) within the dialog code so when the dialog box appears, the beep is triggered?  I've tried placing it in various locations within a  dialog's code without out success.

Thanks much again.

B

_Bruce_Robertson
Level 10
Level 10

Hi,

You could pass in the xfa.host object so you could call the beep() method.  But in a custom dialog the setTimeOut doesn't work, so you could try looping for half a second between beeps.


function dialog()


{


var dialogDescriptor =


{


  description:


  {


   name: "Beep Test",


   elements: [


    {


     type: "button",


     item_id: "beep",


     name: "Beep Beep",


    },


    {


     type: "ok",


    }


   ]


  },


  beep : function(dialog)


  {


   dialogObject.host.beep(1);


   var startTime = Date.now();


   while (Date.now() - startTime < 500) { }


   dialogObject.host.beep(1);


  },


  validate : function(dialog)


  {


   //add validate code here


   return true;


  },


};


var dialogObject =


{


  execDialog: function() { return app.execDialog(dialogDescriptor); },


};


return dialogObject;


}


var d = dialog();


d.host = xfa.host;


d.execDialog();




Acrobat also has an app.beep(1) which you could use.

Regards

Bruce

Brian3_14
Level 3
Level 3

Copy all.  Thanks, as always, Sensei.

Best,

Brian