Ticket #1266 (closed feature: fixed)

Opened 5 years ago

Last modified 5 years ago

prevent the feature handler from stopping the propagation of clicks occuring on features

Reported by: openlayers Owned by: elemoine
Priority: major Milestone: 2.6 Release
Component: Handler.Feature Version: SVN
Keywords: Cc: plists@…
State: Complete

Description

What I want to do is to preserve 'click' functionality even if the click

happened over a draggable feature.

Setting the drag handler's stopDown property to false won't help you because the event you want to get "click" not "mousedown". Anyhow the feature handler (also used in the drag feature control) stops the propagation of clicks that occur on features. That's what kills you here.

Currently, there's no way to prevent the feature handler from stopping the propagation of clicks occuring on features. I think this deserves a ticket and a patch. In the meantime, you can try the patch attached to this email. The patch adds the property stopHandledClick to the feature handler. By default, stopHandledClick is set to true. By making it false, clicks occuring on features will propagate.

So apply the patch and replace

drag.dragHandler.stopDown = false;

with

drag.featureHandler.stopHandledClick = false;

Attachments

patch-r5724-feature-handler-test.diff Download (3.0 KB) - added by openlayers 5 years ago.
patch-1266-r5738-A0.diff Download (5.1 KB) - added by elemoine 5 years ago.
patch including simplified tests
stopHandled.patch Download (5.1 KB) - added by tschaub 5 years ago.
optionally stop handled events

Change History

Changed 5 years ago by openlayers

  Changed 5 years ago by openlayers

  • keywords review added
  • version changed from 2.5 to SVN
  • milestone set to 2.6 Release

  Changed 5 years ago by crschmidt

I think that we should change 'stopHandled' to just 'stop' -- is there any case where we'd have a stopSomethingElseClick option on the handler?

follow-up: ↓ 5   Changed 5 years ago by crschmidt

  • keywords review removed
  • state set to Needs More Work

  Changed 5 years ago by openlayers

  • owner changed from tschaub to elemoine

I just wrote the tests, so I think Eric Lemoine (the original author of the patch) is more competent in answering this, my guess is he wanted to differentiate from the stopDown property. I'm willing to implement the changes, it's just that I don't feel familiar enough with OpenLayers structures/logics to make design choices/suggestions (yet). I'll assign this to him, I hope it's ok that way...

in reply to: ↑ 3   Changed 5 years ago by elemoine

Replying to crschmidt:

Chris, I named the property stopHandledClick because it only pertains to handled clicks. Unhandled (from the feature handler's viewpont) clicks will always propagate, whatever the value of stopHandledClick. This is all explained in the ND comments above the definitions of the new properties. Does it make more sense to you or would you still want to see it otherwise? Thanks.

Changed 5 years ago by elemoine

patch including simplified tests

  Changed 5 years ago by crschmidt

  • state changed from Needs More Work to Review

No, that's cool: it hadn't made sense to me that there were other things than 'handled' clicks that would matter, but I get it noww.

follow-up: ↓ 8   Changed 5 years ago by elemoine

All tests pass on FF.

in reply to: ↑ 7   Changed 5 years ago by elemoine

Replying to elemoine:

All tests pass on FF.

They also pass on IE6, and IE7. On Opera all tests pass except Layer/test_Markers.html that fails due to an opacity issue, which is unrelated to that patch.

  Changed 5 years ago by elemoine

  • priority changed from minor to major

Bumping the priority of this ticket as I think the attached patch should go into 2.6. crschmidt, was the "no that's cool" actually a "good ahead and commit" ? :-)

  Changed 5 years ago by crschmidt

No, no real review has been done by me. I don't know enough here; I'd be deferring to Tim.

Changed 5 years ago by tschaub

optionally stop handled events

  Changed 5 years ago by tschaub

  • state changed from Review to Commit

Eric, I think this is good. I agree with crschmidt about wanting a new name. Instead of stopHandledClick, I like stopClick. This is the feature handler. It should not be used to control events that don't have to do with features (unhandled events). The drag handler has a stopDown. This property is only relevant at the start of a (handled) drag. It has no effect if modifiers or left-click indicate the start of a non-drag. I think it is parallel to call these properties stopDown, stopUp, and stopClick.

Otherwise, the patch looks good to me. I corrected some mixed output in the test results (was mouseup should have been mousedown, was mousedown should have been mouseup), renamed things, and confirmed that tests pass in FF and examples work.

If you like the changes, please commit. If not, let's discuss.

  Changed 5 years ago by tschaub

Original patch came from "openlayers". Not sure if we need another CLA. plists <at> prometheus.org.yu is this you? Have you signed a CLA?

  Changed 5 years ago by openlayers

Yes, that's me (Attila Csipa), and as far as I'm concerned the simplified tests are different enough so I'd be embarrassed to have any of the excellent work done here attributed to me when I only brought some motivation and a little code-nudging to the table :) I have not signed a CLA (yet), but I do plan on expanding my activities regarding submitting patches to OpenLayers/TileCache, just let me know if/when you think my activities are ripe for a CLA or a non-anonymous user login.

  Changed 5 years ago by tschaub

Hey, all contributions appreciated. Please sign a CLA whenever it's convenient. Also, logins are cheap (for me). Just read up on the wiki on how to get one.

  Changed 5 years ago by elemoine

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [5976]) Add properties stopClick, stopDown, and stopUp to the feature handler. If stopClick is true, clicks handled by the feature handler don't propagate to other click listeners; otherwise handled clicks do propagate. The same kind of rule applies to stopDown and stopUp. These properties default to true. Thanks to Attila Csipa for expressing the need for this feature and cooking up the first patch. r=tschaub. (closes #1266)

Note: See TracTickets for help on using tickets.