diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index 2a47496216..d387d3c72b 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -106,17 +106,26 @@ OpenLayers.Events.prototype = { * @param {Event} evt */ triggerEvent: function (type, evt) { + + // prep evt object with object & div references if (evt == null) { - evt = {}; + evt = new Object(); } evt.object = this.object; evt.div = this.div; + // execute all callbacks registered for specified type var listeners = this.listeners[type]; for (var i = 0; i < listeners.length; i++) { var callback = listeners[i]; + + // use the 'call' method to bind the context to callback.obj var continueChain = callback.func.call(callback.obj, evt); - if (continueChain != null && !continueChain) break; + + if ((continueChain != null) && (continueChain == false)) { + // if callback returns false, execute no more callbacks. + break; + } } },