Professional Web Applications Themes

Plug-in toolbar button activation question - Adobe Acrobat SDK

I'm not a plug-in developer and do not foresee becoming one, but I am trying to understand how Acrobat handles custom toolbar buttons that you add via JavaScript. Iím interested in the cEnable parameter that you can specify when using app.addToolbarButton. With it, you can specify a JavaScript expression that sets the value of event.rc to true or false to control whether the toolbar button is enabled or not. What Iím trying to understand is when, exactly, does this expression get evaluated? In my testing, it seems as though it is triggered continuously, but I donít know what particular event(s) ...

  1. #1

    Default Plug-in toolbar button activation question

    I'm not a plug-in developer and do not foresee becoming one, but I am trying to understand how Acrobat handles custom toolbar buttons that you add via JavaScript.

    Iím interested in the cEnable parameter that you can specify when using app.addToolbarButton. With it, you can specify a JavaScript expression that sets the value of event.rc to true or false to control whether the toolbar button is enabled or not. What Iím trying to understand is when, exactly, does this expression get evaluated? In my testing, it seems as though it is triggered continuously, but I donít know what particular event(s) triggers it. It is not doented in the Acrobat JavaScript reference.

    I tried reading through the plug-in related doentation in the SDK to see if I could figure out what event a plug-in would be likely to register for if it needed to be able to disable its toolbar button(s), but came up empty. If a plug-in wanted to disable a toolbar button in a similar manner, what event(s) should it be listening to?

    What is Acrobat using to trigger the evaluation of the code specified with the cEnable parameter for app.addToolbar button? Speculations are welcome if not known.

    Thanks,

    George
    George Johnson Guest

  2. #2

    Default Re: Plug-in toolbar button activation question

    I don't know exactly when this is called/changed. BUT this function is normally an if like statement that tests for something to say whether to enable the toolbutton or not

    for example (pseudo code)

    if ( numDocs > 0)
    {
    return true; // enable
    }
    else
    {
    return false; // disable
    }

    And when you create a plug-in, if it adds a tool button (or men item for that matter) it contains a function which returns true or false based on a similar if statement to above.

    So based on this information I am not sure I understand why you would need to know which event is used to call this function? Please elaborate if I have missed the question you where asking.
    malkyt@adobeforums.com Guest

  3. #3

    Default Re: Plug-in toolbar button activation question

    I'm just trying to complete my understanding of how it all works. Knowing under what conditions the JavaScript code that you specify with the cEnable parameter is executed may have a bearing on what code you decide to use.

    This question arose in my mind when I used some code that I would have expected to work, but did not.

    George
    George Johnson Guest

  4. #4

    Default Re: Plug-in toolbar button activation question

    The code is execute each time the menu is shown. So if you put it under the "Tools" menu, the cEnable code will execute when "Tools" is activated, but before the menu is drawn to screen.
    PDL@adobeforums.com Guest

  5. #5

    Default Re: Plug-in toolbar button activation question

    PDL,

    Thanks for the response, but I'm asking about toolbar buttons.

    George
    George Johnson Guest

  6. #6

    Default Re: Plug-in toolbar button activation question

    Ah, sorry, misread.

    In that case the cEnable code is run when the button loads and each time a doent is opened/closed in that view pane.

    If you're looking to make a custom menu item/toolbar item that is enabled or disabled based on doent content, your best option is to use a menu item.
    PDL@adobeforums.com Guest

  7. #7

    Default Re: Plug-in toolbar button activation question



    In that case the cEnable code is run when the button loads and each time
    a doent is opened/closed in that view pane.




    It's not just limited to that. Whatever event it is, it seems as though it is continually triggered. For example, if I set the cEnable code to be based on the value of a global variable, the button is affected immediately after I alter the global variable:

    cEnable: "event.rc = global.myVar;"

    Then, in the JavaScript console, if I execute:

    global.myvar = false;

    my button immediately becomes disabled. Something must trigger it, and I'm suspecting it's related to the ECMAscript plug-in and may not be an event that other plug-ins can be notified of.

    George
    George Johnson Guest

  8. #8

    Default Re: Plug-in toolbar button activation question

    Using a global variable is a different situation. If you're at all familiar with Flex / ActionScript 3, think of it as a data binding. In that case there is no predefined "event" that is triggered to check for an update, the updating of the binding variable itself triggers the update of all variables bound to it.

    I'm suspecting it's related to the ECMAscript plug-in and may not be an
    event that other plug-ins can be notified of.




    Yes, that is correct - it is not an 'event' and cannot be accessed by other plug-ins.
    PDL@adobeforums.com Guest

Similar Threads

  1. Adding a Textbox to a toolbar for a plug-in
    By Tim_W._James@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 15
    Last Post: August 28th, 01:39 AM
  2. Acrobat 8 ToolBar Button
    By Michael_Wu@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 1
    Last Post: January 10th, 08:06 PM
  3. HOW TO: Add a button to IE Explorer toolbar???
    By svd in forum ASP.NET Building Controls
    Replies: 3
    Last Post: October 10th, 11:54 AM
  4. Help with acrobat toolbar button?
    By pragnyan in forum Adobe Acrobat SDK
    Replies: 0
    Last Post: September 21st, 09:58 AM
  5. Windows XP (re) Activation question.
    By Simon Cook in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 22nd, 06:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139