Bridge: Document loaded event + handled:true = can't close bridge

  • 1
  • Question
  • Updated 1 year ago
  • Answered
Using Bridge 2017 version 7.0.0.93 on windows7, I have some code in a Document loaded event.It works as expected both ways:
    1. when handled:false
    2. when handled:true
   
What is the problem then?
When handled:false, there is no problem.
When handled:true, the listener event works and triggers my code, but when I try to close Bridge, it simply doesn't close. I must force closing it on windows.
Can any one help me?
 
Here is the code:
 
thumbsLoaded_RECURSIVE = function( event ) {  
    // IMPORTANTE: $.hiresTimer > 180000 this triggers only once when the cache folder has been already built  previously  
    if ( event.object instanceof Document && event.type == 'loaded' && $.hiresTimer > 180000) {  
        alert("trigered " + new Date().getTime() + " miliseconds");  
        // ([my code...])  
        // handled:false  > it only triggers when the active folder changes  
        // handled:true  > it  triggers when:  the active folder changes + add files/folders , when mannually reorders the 1st time mannually (invisivel .bridgesort) + when refreshes F5  
    } return {  
        handled:true;  
    }  
}  
app.eventHandlers.push( {handler: thumbsLoaded_RECURSIVE} ); 
Photo of Pedro Marques

Pedro Marques

  • 163 Posts
  • 25 Reply Likes
  • unsure

Posted 2 years ago

  • 1
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Your code give an error in ExtendScript, this works for me Pedro.
thumbsLoaded_RECURSIVE = function( event ) { 
    // IMPORTANTE: $.hiresTimer > 180000 this triggers only once when the cache folder has been already built  previously 
    if ( event.object instanceof Document && event.type == 'loaded' && $.hiresTimer > 180000) { 
        alert(" trigered " + new Date().getTime() + " miliseconds"); 
        // ([my code...]) 
        // handled:false  > it only triggers when the active folder changes 
        // handled:true  > it  triggers when:  the active folder changes + add files/folders , when mannually reorders the 1st time mannually (invisivel .bridgesort) + when refreshes F5 
     return } 
        handled:true; 

app.eventHandlers.push( {handler: thumbsLoaded_RECURSIVE} ); 
Photo of Pedro Marques

Pedro Marques

  • 163 Posts
  • 25 Reply Likes
Hi Paul

In fact, the return must be inside the filter if(event.object....
Mine was outside.
Here is the correct code:

var thumbsLoaded_RECURSIVE = function( event ) {
    if (event.object instanceof Document && event.type == 'loaded' && $.hiresTimer > 180000) {
        //
        $.writeln("Triggered !");
        //
        return {handled:true};  
    }
    // the return was here before
}  
app.eventHandlers.push( {handler: thumbsLoaded_RECURSIVE} ); 
Photo of Gregory Reser

Gregory Reser

  • 3 Posts
  • 0 Reply Likes
Thanks for answering this, Paul.  I was having the same problem.