Changeset 5976
- Timestamp:
- 02/03/08 12:35:39 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Handler/Feature.js (modified) (7 diffs)
- trunk/openlayers/tests/Handler/test_Feature.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Handler/Feature.js
r5975 r5976 73 73 */ 74 74 geometryTypes: null, 75 75 76 /** 77 * Property: stopClick 78 * {Boolean} If stopClick is set to true, handled clicks do not 79 * propagate to other click listeners. Otherwise, handled clicks 80 * do propagate. Unhandled clicks always propagate, whatever the 81 * value of stopClick. Defaults to true. 82 */ 83 stopClick: true, 84 85 /** 86 * Property: stopDown 87 * {Boolean} If stopDown is set to true, handled mousedowns do not 88 * propagate to other mousedown listeners. Otherwise, handled 89 * mousedowns do propagate. Unhandled mousedowns always propagate, 90 * whatever the value of stopDown. Defaults to true. 91 */ 92 stopDown: true, 93 94 /** 95 * Property: stopUp 96 * {Boolean} If stopUp is set to true, handled mouseups do not 97 * propagate to other mouseup listeners. Otherwise, handled mouseups 98 * do propagate. Unhandled mouseups always propagate, whatever the 99 * value of stopUp. Defaults to true. 100 */ 101 stopUp: true, 102 76 103 /** 77 104 * Property: layerIndex … … 107 134 mousedown: function(evt) { 108 135 this.down = evt.xy; 109 return !this.handle(evt);136 return this.handle(evt) ? !this.stopDown : true; 110 137 }, 111 138 … … 120 147 mouseup: function(evt) { 121 148 this.up = evt.xy; 122 return !this.handle(evt);149 return this.handle(evt) ? !this.stopUp : true; 123 150 }, 124 151 … … 135 162 */ 136 163 click: function(evt) { 137 return !this.handle(evt);164 return this.handle(evt) ? !this.stopClick : true; 138 165 }, 139 166 … … 192 219 * 193 220 * Returns: 194 * {Boolean} Stop event propagation.221 * {Boolean} The event occurred over a relevant feature. 195 222 */ 196 223 handle: function(evt) { 197 224 var type = evt.type; 198 var stopEvtPropag= false;225 var handled = false; 199 226 var previouslyIn = !!(this.feature); // previously in a feature 200 227 var click = (type == "click" || type == "dblclick"); … … 213 240 } 214 241 this.lastFeature = this.feature; 215 stopEvtPropag= true;242 handled = true; 216 243 } else { 217 244 // not in to a feature … … 226 253 } 227 254 } 228 return stopEvtPropag;255 return handled; 229 256 }, 230 257 trunk/openlayers/tests/Handler/test_Feature.html
r5506 r5976 122 122 handler.handle("click", {}); 123 123 } 124 124 125 function test_Handler_Feature_callbacks(t) { 125 126 t.plan(9); … … 239 240 } 240 241 242 function test_Handler_Feature_stopHandled(t) { 243 t.plan(3); 244 var map = new OpenLayers.Map('map'); 245 var control = new OpenLayers.Control(); 246 map.addControl(control); 247 var layer = new OpenLayers.Layer(); 248 map.addLayer(layer); 249 var handler = new OpenLayers.Handler.Feature(control, layer); 250 handler.activate(); 251 handler.handle = function(evt) { return /* handled */ true; }; 252 var evtPx = {xy: new OpenLayers.Pixel(Math.random(), Math.random())}; 253 map.events.register("click", map, function(e) { 254 t.ok(!handler.stopClick, "clicks propagate with stopClick set to false" ); 255 }); 256 map.events.register("mousedown", map, function(e) { 257 t.ok(!handler.stopDown, "mousedown propagate with stopDown set to false" ); 258 }); 259 map.events.register("mouseup", map, function(e) { 260 t.ok(!handler.stopUp, "mouseup propagate with stopUp set to false" ); 261 }); 262 263 // 0 test 264 map.events.triggerEvent('click', evtPx); 265 // 0 test 266 map.events.triggerEvent('mousedown', evtPx); 267 // 0 test 268 map.events.triggerEvent('mousedown', evtPx); 269 270 // 1 test 271 handler.stopClick = false; 272 map.events.triggerEvent('click', evtPx); 273 // 1 test 274 handler.stopDown = false; 275 map.events.triggerEvent('mousedown', evtPx); 276 // 1 test 277 handler.stopUp = false; 278 map.events.triggerEvent('mouseup', evtPx); 279 280 // 3 tests total 281 } 241 282 242 283 </script>
