[OpenLayers-Users] How to access mouse
modifier during "featureselected"
Marcel Ruff
mr at marcelruff.info
Wed Feb 10 11:26:09 EST 2010
I have investigated where the event info of a "featureselected" event is
lost:
The events starts at the top of the stack and propagates down to my html
page:
BaseTypes.js bindAsEventListener() evt.altKey evt.button ... OK
Event.js handleBrowserEvent() evt.altKey evt.button
Event.js triggerEvent() evt.altKey evt.button loops over 7
listeners (returns true to chain)
Feature.js click() evt.altKey evt.button
Feature.js handle() evt.altKey evt.button loops to find
the feature
Feature.js triggerCallback() Here the evt object is not available
anymore, details are lost!!!
Handler.js callback()
SelectFeature.js clickFeature()
SelectFeature.js select()
Events.js triggerEvent()
select-feature-multilayer.html Our callback code
In Feature.js triggerCallback() the original event object (which knows
about mouse buttons and meta keys) is lost!
From my point of view, there is no reason to stop delivering
the evt info to the follow-up functions.
What is your opinion?
If I modify the code to transport the original event down
to my listener function, will such a patch be accepted?
Thanks
Marcel
Marcel Ruff schrieb:
> The openlayers lib should be extended to deliver all details:
>
> evt.element
> evt.feature
> evt.object
> evt.type="featureselected"
> evt.button=1; // 1==left mouse, 2==middle mouse, 3==right mouse
> evt.modifier=1; // Shift==1, Ctrl==2 , WindowsKey==8. Alt==3 etc
>
> or probably human readable convenience methods:
>
> e.isLeftPressed()
> e.isMiddlePressed()
> e.isRightPressed()
> e.isAltPressed()
> e.isCtrlPressed()
> ...
>
> Marcel
>
>> On Wed, Feb 10, 2010 at 12:10:10PM +0100, Marcel Ruff wrote:
>>
>>
>>> Ivan Grcic schrieb:
>>>
>>>
>>>> Oh yes, as i see feature handler doesnt have same evt attribs as click
>>>> handler does... so you need to catch click handler of feature handler
>>>> somehow :|
>>>>
>>>>
>>>>
>>> Yes, this is all I get, so no chance to detect which mouse button was
>>> pressed:
>>>
>>> evt.element
>>> evt.feature
>>> evt.object
>>> evt.type="featureselected"
>>>
>>> If I use "click" I need to somehow compute myself which feature was hit ...
>>>
>>> There is no simple solution available?
>>>
More information about the Users
mailing list