Hoping, first, that I'm just making a silly mistake or, if not, to better understand what it means to stopPropagation() on an event.
Consider this snippet:
var beforeCloseListenerTest = app.addEventListener("beforeClose", beforeCloseListenerTest);
function beforeCloseListenerTest(beforeCloseEvent) {
if (beforeCloseEvent.target.constructor.name == "LayoutWindow") { // first beforeClose event
alert("Layout Window is closing. Propagation will be stopped.");
beforeCloseEvent.stopPropagation();
} else {
alert(beforeCloseEvent.target.constructor.name + " is closing.");
} // end if
} // end function
So, when this event listener is running and a document is closed, the alert is displayed saying that the Layout Window is closing. As expected. But the second alert also displays when the Document closes. My brain is stuck on the idea that stopPropagation() should prevent that.
The real event-listener handlers that I'm using all run before the Layout Window closes. It's certainly not a big deal to check the target.constructor,name before deciding whether to do something, but I'm thinking that these scripts would be slightly more efficient if they just stopped at that point.