From e6484453468f82888a306a221f0558f5688e45c9 Mon Sep 17 00:00:00 2001 From: George Michael Brower Date: Mon, 24 Jan 2011 15:08:48 -0700 Subject: [PATCH] Attempt to make text in number boxes unselectable. --- controller.js | 7 +++++++ controller.number.js | 9 +++++++-- controller.string.js | 1 + demo.html | 5 ++--- gui.css | 3 +-- gui.js | 22 +++++++++++----------- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/controller.js b/controller.js index d88e86e..719b420 100644 --- a/controller.js +++ b/controller.js @@ -19,6 +19,13 @@ var Controller = function() { elem.unselectable = "on"; } + this.makeSelectable = function(elem) { + elem.onselectstart = function() { }; + elem.style.MozUserSelect = "auto"; + elem.style.KhtmlUserSelect = "auto"; + elem.unselectable = "off"; + } + this.domElement = document.createElement('div'); this.domElement.setAttribute('class', 'guidat-controller ' + this.type); diff --git a/controller.number.js b/controller.number.js index dfee720..1426266 100644 --- a/controller.number.js +++ b/controller.number.js @@ -43,12 +43,17 @@ var NumberController = function() { }, false); document.addEventListener('mouseup', function(e) { isClicked = false; + _this.makeSelectable(GUI.domElement); + _this.makeSelectable(button); }, false); document.addEventListener('mousemove', function(e) { if(isClicked) { e.preventDefault(); + _this.makeUnselectable(GUI.domElement); + _this.makeUnselectable(button); + py = y; - y = e.offsetY; + y = e.offsetY; var dy = y - py; if(dy < 0) { if(max != null) @@ -64,8 +69,8 @@ var NumberController = function() { } button.value = inc; _this.setValue(inc); - } return false; + } }, false); this.__defineSetter__("position", function(val) { diff --git a/controller.string.js b/controller.string.js index 679e59c..c2bcec7 100644 --- a/controller.string.js +++ b/controller.string.js @@ -11,6 +11,7 @@ var StringController = function() { var initialValue = this.getValue(); input.setAttribute('value', initialValue); + input.setAttribute('spellcheck', 'false'); this.domElement.addEventListener('mouseup', function() { input.focus(); input.select(); diff --git a/demo.html b/demo.html index b80691d..bff85f0 100644 --- a/demo.html +++ b/demo.html @@ -3,12 +3,13 @@ + + -