[OpenLayers-Commits] r3893 - in sandbox/tschaub/wfsv/lib/OpenLayers: . Control Handler
commits at openlayers.org
commits at openlayers.org
Sat Aug 11 11:26:40 EDT 2007
Author: tschaub
Date: 2007-08-11 11:26:40 -0400 (Sat, 11 Aug 2007)
New Revision: 3893
Modified:
sandbox/tschaub/wfsv/lib/OpenLayers/Control/BoundsBox.js
sandbox/tschaub/wfsv/lib/OpenLayers/Control/FeatureEditor.js
sandbox/tschaub/wfsv/lib/OpenLayers/Handler.js
sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Box.js
sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Drag.js
Log:
store evt on handler
Modified: sandbox/tschaub/wfsv/lib/OpenLayers/Control/BoundsBox.js
===================================================================
--- sandbox/tschaub/wfsv/lib/OpenLayers/Control/BoundsBox.js 2007-08-11 14:40:49 UTC (rev 3892)
+++ sandbox/tschaub/wfsv/lib/OpenLayers/Control/BoundsBox.js 2007-08-11 15:26:40 UTC (rev 3893)
@@ -47,9 +47,8 @@
*
* Parameters:
* position - {<OpenLayers.Bounds>} or {<OpenLayers.Pixel>}
- * evt - {Event} The browser event that finished the box.
*/
- returnBounds: function(position, evt) {
+ returnBounds: function(position) {
var bounds;
if(position instanceof OpenLayers.Bounds) {
var minXY = this.map.getLonLatFromPixel(
@@ -65,7 +64,7 @@
bounds = new OpenLayers.Bounds(center.lon, center.lat,
center.lon, center.lat);
}
- this.callback.apply(this.target, [bounds, evt]);
+ this.callback.apply(this.target, [bounds]);
},
CLASS_NAME: "OpenLayers.Control.BoundsBox"
Modified: sandbox/tschaub/wfsv/lib/OpenLayers/Control/FeatureEditor.js
===================================================================
--- sandbox/tschaub/wfsv/lib/OpenLayers/Control/FeatureEditor.js 2007-08-11 14:40:49 UTC (rev 3892)
+++ sandbox/tschaub/wfsv/lib/OpenLayers/Control/FeatureEditor.js 2007-08-11 15:26:40 UTC (rev 3893)
@@ -175,9 +175,8 @@
*
* Parameters:
* bounds - {<OpenLayers.Bounds>}
- * evt - {Event}
*/
- prepareRequest: function(bounds, evt) {
+ prepareRequest: function(bounds) {
var params = {
service: "WFS",
request: "getFeature",
@@ -189,8 +188,7 @@
// TODO: put HTTPRequest.getFullRequestString in Util
var url = this.url + "?" + OpenLayers.Util.getParameterString(params);
- // evt passed along for modifiers - find a better solution
- this.requestFeatures(url, evt);
+ this.requestFeatures(url);
},
/**
@@ -199,10 +197,10 @@
*
* Parameters:
* url - {String}
- * evt - {Event}
*/
- requestFeatures: function(url, evt) {
+ requestFeatures: function(url) {
var callback;
+ var evt = this.featuresControl.handler.evt;
if(evt.shiftKey) {
callback = this.addFeatures;
} else if(evt.ctrlKey) {
Modified: sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Box.js
===================================================================
--- sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Box.js 2007-08-11 14:40:49 UTC (rev 3892)
+++ sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Box.js 2007-08-11 15:26:40 UTC (rev 3893)
@@ -97,7 +97,7 @@
/**
* Method: endBox
*/
- endBox: function(end, evt) {
+ endBox: function(end) {
var result;
if (Math.abs(this.dragHandler.start.x - end.x) > 5 ||
Math.abs(this.dragHandler.start.y - end.y) > 5) {
@@ -115,7 +115,7 @@
// TBD: use CSS classes instead
this.map.div.style.cursor = "";
- this.callback("done", [result, evt]);
+ this.callback("done", [result]);
},
/**
Modified: sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Drag.js
===================================================================
--- sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Drag.js 2007-08-11 14:40:49 UTC (rev 3892)
+++ sandbox/tschaub/wfsv/lib/OpenLayers/Handler/Drag.js 2007-08-11 15:26:40 UTC (rev 3893)
@@ -93,7 +93,7 @@
this.start = evt.xy.clone();
// TBD replace with CSS classes
this.map.div.style.cursor = "move";
- this.callback("down", [evt.xy, evt]);
+ this.callback("down", [evt.xy]);
OpenLayers.Event.stop(evt);
return false;
}
@@ -113,7 +113,7 @@
mousemove: function (evt) {
if (this.started) {
this.dragging = true;
- this.callback("move", [evt.xy, evt]);
+ this.callback("move", [evt.xy]);
if(!this.oldOnselectstart) {
this.oldOnselectstart = document.onselectstart;
document.onselectstart = function() {return false;}
@@ -137,8 +137,8 @@
this.started = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "";
- this.callback("up", [evt.xy, evt]);
- this.callback("done", [evt.xy, evt]);
+ this.callback("up", [evt.xy]);
+ this.callback("done", [evt.xy]);
document.onselectstart = this.oldOnselectstart;
}
return true;
@@ -160,11 +160,11 @@
this.dragging = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "";
- this.callback("out", [evt]);
+ this.callback("out", []);
if(document.onselectstart) {
document.onselectstart = this.oldOnselectstart;
}
- this.callback("done", [evt.xy, evt])
+ this.callback("done", [evt.xy])
}
return true;
},
Modified: sandbox/tschaub/wfsv/lib/OpenLayers/Handler.js
===================================================================
--- sandbox/tschaub/wfsv/lib/OpenLayers/Handler.js 2007-08-11 14:40:49 UTC (rev 3892)
+++ sandbox/tschaub/wfsv/lib/OpenLayers/Handler.js 2007-08-11 15:26:40 UTC (rev 3893)
@@ -198,7 +198,8 @@
*/
register: function (name, method) {
// TODO: deal with registerPriority in 3.0
- this.map.events.registerPriority(name, this, method);
+ this.map.events.registerPriority(name, this, method);
+ this.map.events.registerPriority(name, this, this.setEvent);
},
/**
@@ -207,7 +208,30 @@
*/
unregister: function (name, method) {
this.map.events.unregister(name, this, method);
+ this.map.events.unregister(name, this, this.setEvent);
},
+
+ /**
+ * Method: setEvent
+ * With each registered browser event, the handler sets its own evt
+ * property. This property can be accessed by controls if needed
+ * to get more information about the event that the handler is
+ * processing.
+ *
+ * This allows modifier keys on the event to be checked (alt, shift,
+ * and ctrl cannot be checked with the keyboard handler). For a
+ * control to determine which modifier keys are associated with the
+ * event that a handler is currently processing, it should access
+ * (code)handler.evt.altKey || handler.evt.shiftKey ||
+ * handler.evt.ctrlKey(end).
+ *
+ * Parameters:
+ * evt - {Event} The browser event.
+ */
+ setEvent: function(evt) {
+ this.evt = evt;
+ return true;
+ },
/**
* Method: destroy
More information about the Commits
mailing list