Do not change the active state of button controls on a panel when a tool control is activated. p=jorix, r=me (closes #2764)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10576 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2010-08-04 07:56:25 +00:00
parent 9d3c4ecb1c
commit ea1290f8d8
4 changed files with 78 additions and 14 deletions

View File

@@ -33,12 +33,37 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
* {<OpenLayers.Control>} The control which is activated when the control is
* activated (turned on), which also happens at instantiation.
*/
defaultControl: null,
defaultControl: null,
/**
* Constructor: OpenLayers.Control.Panel
* Create a new control panel.
*
*
* Each control in the panel is represented by an icon. When clicking
* on an icon, the <activateControl> method is called.
*
* Specific properties for controls on a panel:
* type - {Number} One of <OpenLayers.Control.TYPE_TOOL>,
* <OpenLayers.Control.TYPE_TOGGLE>, <OpenLayers.Control.TYPE_BUTTON>.
* If not provided, <OpenLayers.Control.TYPE_TOOL> is assumed.
* title - {string} Text displayed when mouse is over the icon that
* represents the control.
*
* The <OpenLayers.Control.type> of a control determines the behavior when
* clicking its icon:
* <OpenLayers.Control.TYPE_TOOL> - The control is activated and other
* controls of this type in the same panel are deactivated. This is
* the default type.
* <OpenLayers.Control.TYPE_TOGGLE> - The active state of the control is
* toggled.
* <OpenLayers.Control.TYPE_BUTTON> - The
* <OpenLayers.Control.Button.trigger> method of the control is called,
* but its active state is not changed.
*
* If a control is <OpenLayers.Control.active>, it will be drawn with the
* olControl[Name]ItemActive class, otherwise with the
* olControl[Name]ItemInactive class.
*
* Parameters:
* options - {Object} An optional object whose properties will be used
* to extend the control.
@@ -137,7 +162,12 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
/**
* APIMethod: activateControl
*
* This method is called when the user click on the icon representing a
* control in the panel.
*
* The action that triggers depends on the type of control, see the
* description of the types of controls in the method <addControls>.
*
* Parameters:
* control - {<OpenLayers.Control>}
*/
@@ -159,7 +189,8 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
}
for (var i=0, len=this.controls.length; i<len; i++) {
if (this.controls[i] != control) {
if (this.controls[i].type != OpenLayers.Control.TYPE_TOGGLE) {
if (this.controls[i].type === OpenLayers.Control.TYPE_TOOL ||
this.controls[i].type === null) {
this.controls[i].deactivate();
}
}
@@ -174,7 +205,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
* Control Panel.
*
* Parameters:
* controls - {<OpenLayers.Control>}
* controls - {<OpenLayers.Control>} Controls to add in the panel.
*/
addControls: function(controls) {
if (!(controls instanceof Array)) {