Ticket #2204 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

cannot unselect on clickout when selecting by drawing a box

Reported by: elemoine Owned by: elemoine
Priority: minor Milestone: 2.9 Release
Component: Control.SelectFeature Version: 2.8
Keywords: Cc:
State: Complete

Description

This is an issue with the SelectFeature. When selecting features by drawing a box we cannot unselect them with clickout. The issue can be easily reproduced with the select feature example (http://openlayers.org/dev/examples/select-feature.html).

Here's what's going on: when selecting features by drawing a box the feature handler does not participate in the selection so it never triggers the clickout callback. I don't see any other way than faking the feature handler, as done in the attached patch.

Attachments

patch-2204-r9573-A0.diff Download (0.6 KB) - added by elemoine 4 years ago.
patch-2204-r9595-B0.diff Download (1.0 KB) - added by elemoine 4 years ago.

Change History

Changed 4 years ago by elemoine

  Changed 4 years ago by igrcic

Hi,

stange...i was trying to reproduce this but I was unable to do so. Is it only happening with features that have been drawn after to the map?

Because when I load features before, activate control, clickout works out fine for me, after i selected features with box.

follow-up: ↓ 3   Changed 4 years ago by igrcic

...but yes, applying this patch makes selectFeature example to work properly also.

But its still strange to me because I didnt apply patch to my app and its still working properly... (using clean v2.8)

in reply to: ↑ 2   Changed 4 years ago by elemoine

Replying to igrcic:

...but yes, applying this patch makes selectFeature example to work properly also. But its still strange to me because I didnt apply patch to my app and its still working properly... (using clean v2.8)

steps to reproduce the issue:

follow-ups: ↓ 5 ↓ 6   Changed 4 years ago by igrcic

Eric,

yes I manage to reproduce it on example. And it seemed ur patch fixed the problem there. But thers some strange behaviour, maybe because of the example itself and the way it updates control properties? Try this (with patch applied):

  • draw polygons
  • check "select features in a box" and DONT check "click out to unselect features"
  • select features by drawing a box
  • now check "click out to unselect features"
  • clicking out doesn't deselect features

So if we first select features without "click out to unselect features" checked, click out doesnt work.

But I couldnt reproduce it on my app. Until now. Here is my case:

I have ExtJs GridPanel, that I connect with vector layer trough rowselect listener, like this:

listeners: {

rowselect: function(sm, rowIndex, rec){

//find feature trough fid

controlSelectFeature.select(feat);

},

rowdeselect: function(sm, rowIndex, rec){

controlSelectFeature.unselect(feat);

}

First thing that I dont find right: if I DONT add my selectFeature control to map (it is deactivated) my features still get selected when I click on the row on my grid. Does it suppose to work like that, select&unselect func are working even if control is deactivated? I find it strange

So my problem is: When I FIRST select features like that trough grid (controlSelectFeature.select(feat)), I am unable to unselect them by clicking outside of the features, until I actually select one feature with mouse.

(sorry for longer post)

in reply to: ↑ 4   Changed 4 years ago by elemoine

Replying to igrcic:

Eric, yes I manage to reproduce it on example. And it seemed ur patch fixed the problem there. But thers some strange behaviour, maybe because of the example itself and the way it updates control properties? Try this (with patch applied): * draw polygons * check "select features in a box" and DONT check "click out to unselect features" * select features by drawing a box * now check "click out to unselect features" * clicking out doesn't deselect features So if we first select features without "click out to unselect features" checked, click out doesnt work.

This is because the update function in the example re-activates the control each time the "clickout" checkbox is changed. I changed that behavior in [9595].

Changed 4 years ago by elemoine

in reply to: ↑ 4   Changed 4 years ago by elemoine

Replying to igrcic:

So my problem is: When I FIRST select features like that trough grid (controlSelectFeature.select(feat)), I am unable to unselect them by clicking outside of the features, until I actually select one feature with mouse.

patch-2204-r9595-B0.diff Download addresses the case where features are selected using the box handler (this ticket's actual subject) and the case where features are selected programatically.

  • apply the patch
  • open the select-feature.html example
  • draw a polygon
  • activate the select control, with clickout set
  • select the polygon with drawControls.select.select(drawControls.select.layer.features[0]) in the FireBug console
  • unselect the polygon with clickout

  Changed 4 years ago by igrcic

Tnx Eric, it seems that is working just fine now.

I hoped that it will work for  http://trac.openlayers.org/ticket/2205 but unfortunatelly its not the case.

follow-up: ↓ 9   Changed 4 years ago by igrcic

Hi Eric, me again :)

What about this one:

  • select features
  • deactivate select control (leave features selected)
  • activate it again
  • clickout doesnt deselect features

Just to add, in all cases until now, unselecting by drawing a window works, only click doesnt.

in reply to: ↑ 8 ; follow-up: ↓ 10   Changed 4 years ago by elemoine

Replying to igrcic:

Hi Eric, me again :) What about this one: * select features * deactivate select control (leave features selected) * activate it again * clickout doesnt deselect features Just to add, in all cases until now, unselecting by drawing a window works, only click doesnt.

This is expected and out of the scope of this ticket.

in reply to: ↑ 9   Changed 4 years ago by igrcic

Replying to elemoine:

This is expected and out of the scope of this ticket.

Should I open new improvment ticket for that? Cheers

  Changed 3 years ago by pgiraud

  • state set to Commit

I can confirm that Eric's patch fixes the problem. I'll update OpenLayers in a project I'm working on as soon as it gets committed, because I actually need it. Thanks for this nice work, you can commit.

Irgcic, I suggest you open a new ticket for your problem which seems not directly linked to the current one.

  Changed 3 years ago by elemoine

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

(In [9979]) cannot unselect on clickout when selecting by drawing a box, r=pgiraud (closes #2204)

Note: See TracTickets for help on using tickets.