OpenLayers OpenLayers

Ticket #1378 (reopened bug)

Opened 10 months ago

Last modified 2 months ago

clicking next to the map causes selection of controls

Reported by: tschaub Assigned to:
Priority: minor Milestone: 2.8 Release
Component: Control Version: 2.5
Keywords: Cc:
State:

Description

This regression was introduced in r6176.

Attachments

allowSelection.patch (1.5 kB) - added by crschmidt on 03/30/08 18:13:56.
allowSelection.2.patch (4.2 kB) - added by crschmidt on 03/31/08 01:10:26.

Change History

03/06/08 23:10:44 changed by crschmidt

  • state set to Needs Discussion.

Okay, so:

  1. Unfortunately, Firefox treats clicks inside a div which is cropped by 'overflow:hidden' as clicks that cause selection
  2. We now have a state that allows for things in the map container to be selected, which we didn't before
  3. We allow controls to be selected, because they don't have a shared className that makes it easy to prevent this.

Possible solutions:

  • Add a className to all controls so that they can limit/turn off selection in one CSS rule
  • Explicitly add CSS rules to controls we care most about selecting accidentally. Examples which all outside this: MousePosition? LayerSwitcher? These could theoretically use the abililty to have the user select them, so might make sense to leave them out.
  • Others?

03/19/08 15:15:34 changed by sderle

I vote for "Add a className to all controls so that they can limit/turn off selection in one CSS rule"

03/27/08 17:16:16 changed by bjorn

In IE this cannot be controlled with CSS, but there is another way which was used to (hopefully) resolve #1410. In short, setting element attribute unselectable to on makes it possible to handle onselectstart which normally only works on the document.

This solution was found here: http://adamplatti.net/blog/2007/04/05/the-easiest-way-to-make-html-text-unselectable

The above only helps for stopping selection originating on the element ifself though, so while it does not solve the problem when selection is coming from outside the map, it does solve issues specific to IE similar to #1410. An example is when holding and dragging the mouse on the MousePosition control. This causes selection inside the map div, possibly selecting other controls or VML elements.

03/30/08 18:13:56 changed by crschmidt

  • attachment allowSelection.patch added.

03/30/08 18:15:16 changed by crschmidt

  • state changed from Needs Discussion to Review.

Patch attached:

  • Adds 'allowSelection' property to controls.
  • Default is false.
  • If allowSelection is not true, adds a CSS class name (olControlNoSelect) and uses the IE specific mechanisms for preventing selection.
  • olControlNoSelect contains -moz-user-select: none.

Tested to fix the issue in Firefox.

03/31/08 01:10:26 changed by crschmidt

  • attachment allowSelection.2.patch added.

03/31/08 01:21:07 changed by crschmidt

Several classes set the displayName on the object themselves, instead of letting the base control do it. this isn't really neccesary, since the result is the same either way: the only difference is that we're duplicating code that way, which ends up causing the allowSelection code to not work.

This replaces any case where a control was setting a className explicitly when it shouldn't have been, and as a result, fixes the selection issues for:

03/31/08 01:53:16 changed by euzuro

  • state changed from Review to Commit.

patch is good. tests pass in ie6 & ff please committing

03/31/08 01:55:13 changed by crschmidt

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

(In [6727]) Add 'allowSelection' option to controls, to determine whether they allow selection. Use CSS ClassName in FF, and onselectstart attribute in IE, to control selection. Fix inappropriate overriding of className in some Control subclasses in order to let this work. Prevents accidental selection of controls in IE and FF. r=euzuro. (Closes #1378)

10/01/08 09:01:29 changed by pgiraud

  • status changed from closed to reopened.
  • resolution deleted.
  • state deleted.
  • component changed from general to Control.
  • milestone changed from 2.6 Release to 2.8 Release.

I'm reopening this ticket because it seems like some buttons in some controls don't take the onselectstart in IE. For example, in the controls.html example, most of the buttons in the panZoomBar control can be selected. To see that, you can click down on a button and move the mouse outside the map viewport, elements are then hilighted in blue. I currently have no clue why this is doing so.