Hello List,

Following up from a previous post I made last week, I've been trying
to configure a map that has one control that persistently listens for
and responds to either rightclick or a modifier key + leftclick event
(e.g., ctrl+leftclick).  So what I'm doing is adding a keyMask to all
the controls/handlers for other objects I'm creating.  I ran into a
bit of an issue with this for the Measure control, as it does not seem
to recognize the keyMask option, and adding this to the handlerOptions
for the control did not work either.  So after some digging around, I
found that I had to add some additional checks  in the Point and Path
handlers.

In the Point handler, I changed the click and mousedown methods, and
the in the Path handler I changed the mousedown method, as indicated
below, to include the checkModifiers verification as well as a check
for the left-click event.  Is this something that would be considered
a bug or feature that could be addressed?  If so, I'll submit a ticket
for it...but I'd be interested to know if anyone has any further
comments.  For the time being, I'm creating my own subclasses that
override these functions.

Here's my modified snippets:

====================
In OpenLayers.Handler.Point:
...
        click: function(evt) {
                if(!this.checkModifiers(evt) || 
!OpenLayers.Event.isLeftClick(evt)) {
                        return true;
                }
                OpenLayers.Event.stop(evt);
                return false;
        },
...
        mousedown: function(evt) {
                // check keyboard modifiers
                if(!this.checkModifiers(evt) || 
!OpenLayers.Event.isLeftClick(evt)) {
                        return true;
                }
                // ignore double-clicks
                if(this.lastDown && this.lastDown.equals(evt.xy)) {
                        return true;
                }
                this.drawing = true;
                if(this.lastDown == null) {
                        if(this.persist) {
                                this.destroyFeature();
                        }
                        this.createFeature(evt.xy);
                } else {
                        this.modifyFeature(evt.xy);
                }
                this.lastDown = evt.xy;
                return false;
        }
...

In OpenLayers.Handler.Path:
...
        mousedown: function(evt) {
                // check keyboard modifiers
                if(!this.checkModifiers(evt) || 
!OpenLayers.Event.isLeftClick(evt)) {
                        return true;
                }
                // ignore double-clicks
                if (this.lastDown && this.lastDown.equals(evt.xy)) {
                        return false;
                }
                if(this.lastDown == null) {
                        if(this.persist) {
                                this.destroyFeature();
                        }
                        this.createFeature(evt.xy);
                } else if((this.lastUp == null) || !this.lastUp.equals(evt.xy)) 
{
                        this.addPoint(evt.xy);
                }
                this.mouseDown = true;
                this.lastDown = evt.xy;
                this.drawing = true;
                return false;
        },
...
===================

Regards,
Mike
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to