These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

enable/disablie a toolbar button

fursten
Registered: Feb 14 2007
Posts: 14

Hello,
 
I created a toolbar button using a code similar to this (inside an app.trustedFunction):
 
app.addToolButton({
cName: "applyMetaData",
cLabel: "MetaData",
cEnable: "event.rc = (app.doc != null);",
cExec: "function_name();"});
 
So, after my pdf is open, The toolbar will display this button.
 
However, after that, I would like to control the enable/disable state of this button. Is this possible?
 
I tried to use a reference to the button variable, but I realized that despite being able to read the properties of the button (and actual, setting them), I cannot enable/disable the button.
 
Thank you.

My Product Information:
Reader 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The enabled state of a toolbar button is controlled entirely through the "cEnable" script, which is set when the button is created. You can't change the button after that so this script has to be setup exactly the way you want.

some questions.
1) What do you mean by "after my pdf is open, The toolbar will display this button"?

You defined a trusted function for button creation in a folder level Script. Are you calling the function from a document script, or is the button created when Acrobat is started.

2) What do you mean by "tried to use a reference to the button variable"?

As far as I know, no such animal exists in Acrobat JavaScript.

Thom Parker
WindJack Solutions
[url=http://www.windjack.com]www.windjack.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

fursten
Registered: Feb 14 2007
Posts: 14
Hi,

The toolbar is created only after my document is open and not when acrobat is started. So, in the initialize event of my form I call a javascript folder function that will create the button.

After that I would like to control the state enable/disable of the button. For instance, if I click on a button in the pdf I woul like to disable the toolbar button.


"tried to use a reference to the button variable"?
-> just to say that I can read the properties of the button at any time, but not change them (well, it is just a global variable in the script).Thank you.