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) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6727 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -78,6 +78,15 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
*/
|
||||
type: null,
|
||||
|
||||
/**
|
||||
* Property: allowSelection
|
||||
* {Boolean} By deafault, controls do not allow selection, because
|
||||
* it may interfere with map dragging. If this is true, OpenLayers
|
||||
* will not prevent selection of the control.
|
||||
* Default is false.
|
||||
*/
|
||||
allowSelection: false,
|
||||
|
||||
/**
|
||||
* Property: displayClass
|
||||
* {string} This property is used for CSS related to the drawing of the
|
||||
@@ -240,6 +249,11 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
if (this.div == null) {
|
||||
this.div = OpenLayers.Util.createDiv(this.id);
|
||||
this.div.className = this.displayClass;
|
||||
if (!this.allowSelection) {
|
||||
this.div.className += " olControlNoSelect";
|
||||
this.div.setAttribute("unselectable", "on", 0);
|
||||
this.div.onselectstart = function() { return(false); };
|
||||
}
|
||||
if (this.title != "") {
|
||||
this.div.title = this.title;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user