Skip to main content
Inspiring
March 13, 2013
Answered

How to set a Navbar to load just after Bridge stars?

  • March 13, 2013
  • 1 reply
  • 856 views

Hi all

I´ve written a script to add 3 buttons to a top navbar. Running from Extended Script works perfectlly. However when adding this script to Bridge´s startup folder (to run it one Bridge opens)..then I get an erro. This could be because a script should wait until the loader finishes. But how I could tell Bridge to run this script after Bridge completes loading the panels???

Here´s the code:

var b = app.document.navbars.filesystem.bottom;

b.height = 50;

b.visible = true;

var b1 = b.add ("button",[0,0,0,0],"Button 1...");

b1.size = [200,30];

b1.location = [10,10];

var b2 = b.add ("button",[0,0,0,0], "Button 2...");

b2.size = [200,30];

b2.location = [230,10];

var b3 = b.add ("button",[0,0,0,0], "Button 3...");

b3.size = [200,30];

b3.location = [450,10];

---

Best Regards

Gustavo.

This topic has been closed for replies.
Correct answer Muppet Mark

Yeah I think you are trying to load this before the document is there…

#target bridge

onDocLoaded = function( event ) {

          if ( event.object instanceof Document && event.type == 'loaded' ) {

                    loadNavButtons();

                    return { handled: true };

          };

};

function loadNavButtons() {

          var b = app.document.navbars.filesystem.bottom;

          b.height = 50;

          b.visible = true;

          var b1 = b.add ("button",[0,0,0,0],"Button 1...");

          b1.size = [200,30];

          b1.location = [10,10];

          var b2 = b.add ("button",[0,0,0,0], "Button 2...");

          b2.size = [200,30];

          b2.location = [230,10];

          var b3 = b.add ("button",[0,0,0,0], "Button 3...");

          b3.size = [200,30];

          b3.location = [450,10];

};

// Register event handler

app.eventHandlers.push( { handler: onDocLoaded } );

1 reply

Muppet MarkCorrect answer
Inspiring
March 14, 2013

Yeah I think you are trying to load this before the document is there…

#target bridge

onDocLoaded = function( event ) {

          if ( event.object instanceof Document && event.type == 'loaded' ) {

                    loadNavButtons();

                    return { handled: true };

          };

};

function loadNavButtons() {

          var b = app.document.navbars.filesystem.bottom;

          b.height = 50;

          b.visible = true;

          var b1 = b.add ("button",[0,0,0,0],"Button 1...");

          b1.size = [200,30];

          b1.location = [10,10];

          var b2 = b.add ("button",[0,0,0,0], "Button 2...");

          b2.size = [200,30];

          b2.location = [230,10];

          var b3 = b.add ("button",[0,0,0,0], "Button 3...");

          b3.size = [200,30];

          b3.location = [450,10];

};

// Register event handler

app.eventHandlers.push( { handler: onDocLoaded } );

Inspiring
March 14, 2013

Very direct and perfect Muppet!

Thank you so much

I copied the code and worked but I assume I do not know the portion of code you wrote. I need to learn how to register these events in Bridge haha.

Does Bridge JavaScript reference covers it?

Best Regards

Gustavo.

Inspiring
March 14, 2013

Yeap the Bridge guide covers events… You need to tell the what event you are interested in tracking… Then provide a function of what to do when the event happens… Here you buttons won't be added until a document window has opened and loaded…