[OpenLayers-Dev] deactivating other handlers
tschaub at openplans.org
Fri Oct 26 11:28:11 EDT 2007
Bart van den Eijnden (OSGIS) wrote:
> Hi devs,
> I've written a FeatureInfo Handler, which only uses click. However, the
> DragPan handler for instance is still active.
Not sure exactly what your FeatureInfo handler does, but it feels like
it might be more of a control than a handler. Perhaps it could be a
control that used the Feature handler (which can be configured to
respond to a click)?
Or maybe it does something like GetFeatureInfo (from WMS)? In this
case, it should almost certainly be a control (because it doesn't
represent a complex sequence of browser events).
> What is the best way to deactivate these other handlers?
Handlers are designed to abstract out sequences of browser events. They
are typically sent to controls to modify the behavior of a control.
When you activate a control, the appropriate handlers are activated.
Deactivate, and the handlers are deactivated.
We want there to be many controls in a given mapping app. Perhaps many
will be active at one time. In this case, any handlers associated with
these controls need to play well together. The order of activation is
important. Controls (and their handlers) that are activated later get
priority in event handling.
> Is there a way to make a Handler exclusive, or to remove all other handlers
> from the map?
It wouldn't make sense necessarily to silence (or plug the ears of
maybe) all handlers on the map. This would be akin to unregistering all
event listeners just because you want to register a new one.
You're better off having your application control the order of control
(and hence handler) activation. This is a somewhat tedious task.
Because of this, we have a control panel class. If you add a tool type
control to a control panel, when it is activated (and it's handler is
activated), it will deactivate all other tool type controls (and their
handlers) on the same panel.
I think this structure gives enough to work with in most situations.
Perhaps I've totally missed what you're trying to do though. If you
give more detail, I can try again.
> Best regards,
> Bart van den Eijnden
> OSGIS, Open Source GIS
> Dev mailing list
> Dev at openlayers.org
More information about the Dev