[OpenLayers-Trac] Re: [OpenLayers] #2834: Panel control: Allow to
use "autoActivate" in the panel's controls.
OpenLayers
trac-20090302 at openlayers.org
Wed Sep 22 12:11:37 EDT 2010
#2834: Panel control: Allow to use "autoActivate" in the panel's controls.
---------------------------+------------------------------------------------
Reporter: jorix | Owner:
Type: feature | Status: new
Priority: minor | Milestone: 2.11 Release
Component: Control.Panel | Version: 2.10
Keywords: | State: Needs More Work
---------------------------+------------------------------------------------
Comment(by jorix):
Replying to [comment:5 ahocevar]:
> Replying to [comment:4 jorix]:
> > Help me to understand the problem, thanks.
>
> I think this should just be
> {{{
> this.map.addControl(control);
> }}}
See following case in "addControlsToMap" using only
{{{this.map.addControl(control);}}}:
{{{
var panel = new OpenLayers.Control({autoActivate:false});
var control1 = new OpenLayers.Control({autoActivate:true});
map.addControl(panel);
panel.addControls([control1]);
}}}
the {{{control1}}} is activated before the {{{panel}}} is activated and
displayed, this is the problem.[[BR]]
For this reason I think code in "addControlsToMap" should be complex[[BR]]
(can remove the "{{{control.deactivate();}}}" in "else", when I wrote the
#2769 I thought I would give more work to remove it and justify, that not
touching)
and replying to comment:6
> In addition to the above, you will have to take care of TOOL controls.
The best way to do this would be to make better use of the activate and
deactivate events of the controls in the panel.
Yes, yes, I agree with you. I've worked a bit in this direction. But there
is a problem: See #1414 and
http://trac.osgeo.org/openlayers/ticket/2306#comment:1 [[BR]]
This requires, in activate events of the controls, something as:
{{{
...
if (control.type == OpenLayers.Control.TYPE_TOOL) {
for (var c, i=0, l=panel.controls.length; i<l; i++) {
c = panel.controls[i];
if ((c.type == OpenLayers.Control.TYPE_TOOL || c.type == null) &&
c !== control) {
c.deactivate();
control.deactivate(); // ups!
control.activate(); // ups!^2
return; // ups!^4
}
}
}
}
}}}
or similar, to ensure that the control is activated after any
deactivation. But is not nice, I have it on a siding.
(looking at "{{{c.type == OpenLayers.Control.TYPE_TOOL || c.type ==
null}}}" I think some time would be good to put: {{{c.type = c.type ||
OpenLayers.Control.TYPE_TOOL;}}} in "addControls", seems right for this
ticket?)
--
Ticket URL: <http://trac.openlayers.org/ticket/2834#comment:7>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list