[fusion-commits] r1649 - in trunk: lib widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri Nov 7 14:55:10 EST 2008
Author: madair
Date: 2008-11-07 14:55:10 -0500 (Fri, 07 Nov 2008)
New Revision: 1649
Modified:
trunk/lib/Map.js
trunk/widgets/Navigator.js
trunk/widgets/Select.js
trunk/widgets/Zoom.js
Log:
re #152: deactivate controls and handlers when the mouse is over the Navigator widget; widgets using the canvasTool will still click through to the map however until the canvas tool is converted to use OL handlers or replaced with OL vector drawing capabilities
Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js 2008-11-07 18:52:22 UTC (rev 1648)
+++ trunk/lib/Map.js 2008-11-07 19:55:10 UTC (rev 1649)
@@ -73,7 +73,7 @@
/**
* construct a new view Fusion.Widget.Map class.
*/
- initialize : function(widgetTag, mapGroup, widgetSet) {
+ initialize : function(widgetTag, mapGroup, widgetSet) {
this.widgetTag = widgetTag;
var name = widgetTag.name;
this.buttonSet = new Jx.ButtonSet();
@@ -130,6 +130,8 @@
this.oMapOL.viewPortDiv.style.position = 'absolute'; //not the top level container so set it to absolute
this.oMapOL.viewPortDiv.style.zIndex = 0; //must explicitly set the z-index for FF3
+ this.handlers = [];
+
//add in the handler for mouse wheel actions
var useMouseWheel = true;
if (widgetTag.extension.DisableMouseWheel &&
@@ -142,6 +144,7 @@
"down": this.wheelDown} );
this.wheelHandler.map = this.oMapOL;
this.wheelHandler.activate();
+ this.handlers.push(this.wheelHandler);
}
//create the 'Map' layer widgets defined in the MapGroup
Modified: trunk/widgets/Navigator.js
===================================================================
--- trunk/widgets/Navigator.js 2008-11-07 18:52:22 UTC (rev 1648)
+++ trunk/widgets/Navigator.js 2008-11-07 19:55:10 UTC (rev 1649)
@@ -35,6 +35,8 @@
zoomOutFactor: 2,
panAmount: 50,
initializeWidget: function(widgetTag) {
+ this.activeControls = [];
+
var m = document.createElement('map');
m.name = 'Navigator_ImageMap';
m.id = 'Navigator_ImageMap';
@@ -146,6 +148,11 @@
this.domObj.style.width = '51px';
this.domObj.style.height = '204px';
this.domObj.style.cursor = 'pointer';
+ // need to disable active map controls when the mouse is over the navigator
+ this.domObj.addEvents({
+ mouseenter: OpenLayers.Function.bind(this.mouseEnter,this),
+ mouseleave: OpenLayers.Function.bind(this.mouseLeave,this)
+ });
var checkPosition = OpenLayers.Function.bind(this.checkPosition, this);
@@ -247,41 +254,51 @@
pan: function(x,y,e) {
//console.log('pan by : ' + x + ', ' + y);
var map = this.getMap();
- var activeWidget = null;
- if (map.oActiveWidget) {
- activeWidget = map.oActiveWidget;
- map.deactivateWidget(map.oActiveWidget);
- }
var center = map.getCurrentCenter();
var res = map.oMapOL.getResolution();
var size = map.oMapOL.getSize();
map.zoom(center.x + (x * size.w * res), center.y + (y * size.h * res), 1);
//new Event(e).stop();
- //OpenLayers.Event.stop(e);
- if (activeWidget) {
- map.activateWidget(activeWidget);
- }
-
+ OpenLayers.Event.stop(e);
return false;
},
zoom: function(factor, e) {
//console.log('zoom by factor: ' + factor);
var map = this.getMap();
- var activeWidget = null;
- if (map.oActiveWidget) {
- activeWidget = map.oActiveWidget;
- map.deactivateWidget(map.oActiveWidget);
- }
var center = map.getCurrentCenter();
map.zoom(center.x, center.y, factor);
- //OpenLayers.Event.stop(e);
- if (activeWidget) {
- map.activateWidget(activeWidget);
- }
+ OpenLayers.Event.stop(e);
return false;
},
+ mouseEnter: function() {
+ var mapWidget = this.getMap();
+ var mapOL = mapWidget.oMapOL;
+ for (var i=0; i<mapOL.controls.length; ++i) {
+ var control = mapOL.controls[i];
+ if (control.active) {
+ control.deactivate();
+ this.activeControls.push(control);
+ }
+ }
+ for (var i=0; i<mapWidget.handlers.length; ++i) {
+ var handler = mapWidget.handlers[i];
+ if (handler.active) {
+ handler.deactivate();
+ this.activeControls.push(handler);
+ }
+ }
+ },
+
+ mouseLeave: function() {
+ var mapOL = this.getMap().oMapOL;
+ while (this.activeControls.length>0) {
+ var control = this.activeControls.pop();
+ control.activate();
+ }
+ },
+
busyChanged: function() {
this.activityIndicator.style.visibility = this.getMap().isBusy() ? 'visible' : 'hidden';
}
Modified: trunk/widgets/Select.js
===================================================================
--- trunk/widgets/Select.js 2008-11-07 18:52:22 UTC (rev 1648)
+++ trunk/widgets/Select.js 2008-11-07 19:55:10 UTC (rev 1649)
@@ -68,10 +68,14 @@
this.getMap().registerForEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, OpenLayers.Function.bind(this.enable, this));
}
- this.map = this.getMap().oMapOL;
+ var mapWidget = this.getMap();
+ this.map = mapWidget.oMapOL;
this.handler = new OpenLayers.Handler.Box(this,{done: this.execute},{keyMask:0});
this.shiftHandler = new OpenLayers.Handler.Box(this,{done: this.extend},
{keyMask:OpenLayers.Handler.MOD_SHIFT});
+ mapWidget.handlers.push(this.handler);
+ mapWidget.handlers.push(this.shiftHandler);
+
},
enable: function() {
Modified: trunk/widgets/Zoom.js
===================================================================
--- trunk/widgets/Zoom.js 2008-11-07 18:52:22 UTC (rev 1648)
+++ trunk/widgets/Zoom.js 2008-11-07 19:55:10 UTC (rev 1649)
@@ -50,10 +50,13 @@
this.keypressWatcher = OpenLayers.Function.bind(this.keypressHandler, this);
- this.map = this.getMap().oMapOL;
+ var mapWidget = this.getMap();
+ this.map = mapWidget.oMapOL;
this.handler = new OpenLayers.Handler.Box(this, {done: this.execute}, {keyMask:0});
this.shiftHandler = new OpenLayers.Handler.Box(this, {done: this.altZoom},
{keyMask:OpenLayers.Handler.MOD_SHIFT});
+ mapWidget.handlers.push(this.handler);
+ mapWidget.handlers.push(this.shiftHandler);
},
/**
More information about the fusion-commits
mailing list