Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

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

Avatar

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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

Avatar

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

Avatar

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

Avatar

Level 3

Copy all.  Thanks, as always, Sensei.

Best,

Brian