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

Brian3_14

01-05-2015

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

Accepted Solutions (1)

Accepted Solutions (1)

_Bruce_Robertson

MVP

02-05-2015

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

Answers (3)

Answers (3)

_Bruce_Robertson

MVP

03-05-2015

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

03-05-2015

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