Skip to main content
Inspiring
Mar 13, 2013 4:39 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
Muppet MarkCorrect answer
Inspiring
Mar 14, 2013 7:44 AM UTC

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 } );

4 replies

Muppet MarkCorrect answer
Inspiring
Mar 14, 2013 7:44 AM UTC

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 } );

Translate
Inspiring
Mar 14, 2013 12:10 PM UTC

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.

Translate
Inspiring
Mar 14, 2013 12:45 PM UTC

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…

Translate