Changeset 7682
- Timestamp:
- 08/02/08 22:06:31 (4 months ago)
- Files:
-
- trunk/openlayers/examples/select-feature.html (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Handler/Feature.js (modified) (1 diff)
- trunk/openlayers/tests/Handler/Feature.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/examples/select-feature.html
r7589 r7682 24 24 map.addLayers([wmsLayer, vectors]); 25 25 map.addControl(new OpenLayers.Control.LayerSwitcher()); 26 map.addControl(new OpenLayers.Control.MousePosition());27 26 28 27 drawControls = { … … 44 43 multipleKey: "shiftKey", // shift key adds to selection 45 44 box: true 45 } 46 ), 47 selecthover: new OpenLayers.Control.SelectFeature( 48 vectors, 49 { 50 multiple: false, hover: true, 51 toggleKey: "ctrlKey", // ctrl key removes from selection 52 multipleKey: "shiftKey" // shift key adds to selection 46 53 } 47 54 ) … … 108 115 </li> 109 116 <li> 117 <input type="radio" name="type" value="selecthover" id="selecthoverToggle" 118 onclick="toggleControl(this);" /> 119 <label for="selecthoverToggle">Select features on hover</label> 120 </li> 121 <li> 110 122 <input type="radio" name="type" value="select" id="selectToggle" 111 123 onclick="toggleControl(this);" /> … … 122 134 <label for="clickout">click out to unselect features</label> 123 135 </li> 124 <li>125 <input id="hover" type="checkbox"126 name="hover" onchange="update()" />127 <label for="hover">hover to select features</label>128 </li>129 136 </ul> 130 137 </li> trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js
r7616 r7682 129 129 OpenLayers.Control.prototype.initialize.apply(this, [options]); 130 130 this.layer = layer; 131 this.callbacks = OpenLayers.Util.extend({ 132 click: this.clickFeature, 133 clickout: this.clickoutFeature, 134 over: this.overFeature, 135 out: this.outFeature 136 }, this.callbacks); 131 var callbacks = { 132 click: this.clickFeature, 133 clickout: this.clickoutFeature 134 }; 135 if (this.hover) { 136 callbacks.over = this.overFeature; 137 callbacks.out = this.outFeature; 138 } 139 140 this.callbacks = OpenLayers.Util.extend(callbacks, this.callbacks); 137 141 this.handlers = { 138 142 feature: new OpenLayers.Handler.Feature( trunk/openlayers/lib/OpenLayers/Handler/Feature.js
r6564 r7682 177 177 */ 178 178 mousemove: function(evt) { 179 if (!this.callbacks['over'] && !this.callbacks['out']) { 180 return false; 181 } 179 182 this.handle(evt); 180 183 return true; trunk/openlayers/tests/Handler/Feature.html
r6719 r7682 178 178 map.events.triggerEvent('click', evtPx); 179 179 180 layer.getFeatureFromEvent = function(evt) { t.fail("mousemove called getFeatureFromEvent without any mousemove callbacks"); }; 181 evtPx.type = "mousemove"; 182 map.events.triggerEvent('mousemove', evtPx); 183 layer.getFeatureFromEvent = function(evt) { return newFeature; }; 184 180 185 // test over a new feature 181 186 // only 'over' callback should be called
