[Laszlo-checkins] r14183 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml
hqm@openlaszlo.org
hqm at openlaszlo.org
Wed Jun 17 18:10:18 PDT 2009
Author: hqm
Date: 2009-06-17 18:10:16 -0700 (Wed, 17 Jun 2009)
New Revision: 14183
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js
openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
Log:
Change 20090617-hqm-c by hqm at badtzmaru.home on 2009-06-17 14:39:12 EDT
in /Users/hqm/openlaszlo/trunk5
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: further fixes for text selection in DHTML
New Features:
Bugs Fixed: LPP-8252
Technical Reviewer: andre
QA Reviewer: max
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
+ fix for getSelectedText to return proper string value
+ conditionalized binding of document.onselectstart to custom function for IE
Tests:
+ first test case in bug report
Open the component sample application [2], mouse down in upper left corner and move cursor to lower right corner.
Expected: no selection on <img> elements
Actual: Firefox/Safari shows selection
Fix: apply changes for "getSelectedText()" as described above
+ second test case in bug report
Also open the component sampler, mouse down and then move cursor while still holding the mouse button.
Expected: no text selection
Actual: text selection for all text elements
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js 2009-06-18 00:29:54 UTC (rev 14182)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js 2009-06-18 01:10:16 UTC (rev 14183)
@@ -1087,3 +1087,21 @@
}
}
+// prevent text selection in IE
+// can't use lz.embed.attachEventHandler because we need to cancel events
+
+if (LzSprite.prototype.quirks.ie_prevent_selection) {
+ document.onselectstart = function () {
+ var src = window.event.srcElement;
+ if (src.owner instanceof LzTextSprite) {
+ if (! src.owner.selectable) {
+ //Debug.write("prevent selection on non-selectable text")
+ return false;
+ }
+ } else {
+ //Debug.write("prevent selection on non-text")
+ return false;
+ }
+ }
+}
+
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js 2009-06-18 00:29:54 UTC (rev 14182)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js 2009-06-18 01:10:16 UTC (rev 14183)
@@ -32,8 +32,6 @@
LzKeyboardKernel.__updateControlKeys(e);
}
- // check source.owner of event, see if textfield and selectable, then don't cancel event
-
var lzinputproto = window['LzInputTextSprite'] && LzInputTextSprite.prototype;
if (lzinputproto && lzinputproto.__lastshown != null) {
if (LzSprite.prototype.quirks.fix_ie_clickable) {
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2009-06-18 00:29:54 UTC (rev 14182)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js 2009-06-18 01:10:16 UTC (rev 14183)
@@ -101,7 +101,7 @@
div.mouseisover = false;
div.onmouseover = function(e) {
if (LzSprite.prototype.quirks.focus_on_mouseover) {
- if (LzSprite.prototype.getSelectedText() == null) {
+ if (LzSprite.prototype.getSelectedText() != "") {
div.focus();
}
}
@@ -146,7 +146,7 @@
}
if (quirks.focus_on_mouseover) {
if (LzInputTextSprite.prototype.__lastshown == null) {
- if (LzSprite.prototype.getSelectedText() == null) {
+ if (LzSprite.prototype.getSelectedText() == "") {
div.focus();
}
}
@@ -158,7 +158,7 @@
} else {
if (quirks.focus_on_mouseover) {
if (LzInputTextSprite.prototype.__lastshown == null) {
- if (LzSprite.prototype.getSelectedText() == null) {
+ if (LzSprite.prototype.getSelectedText() == "") {
div.blur();
}
}
@@ -462,6 +462,7 @@
,fix_ie_clickable: false
,ie_alpha_image_loader: false
,ie_leak_prevention: false
+ ,ie_prevent_selection: false
,ie_elementfrompoint: false
,invisible_parent_image_sizing_fix: false
,emulate_flash_font_metrics: true
@@ -559,6 +560,7 @@
// prevent duplicate image loads - see http://support.microsoft.com/?scid=kb;en-us;823727&spid=2073&sid=global and http://misterpixel.blogspot.com/2006/09/forensic-analysis-of-ie6.html
quirks['ie6_improve_memory_performance'] = true;
} else {
+ quirks['ie_prevent_selection'] = true;
quirks['invisible_parent_image_sizing_fix'] = true;
if (browser.osversion >= 6) {
// IE7 on Vista (osversion=6) needs the alpha image loader
@@ -2380,9 +2382,9 @@
LzSprite.prototype.getSelectedText = function () {
var txt = '';
if (window.getSelection) { // FF/Safari/Opera/Chrome
- return window.getSelection();
+ return window.getSelection().toString();
} else if (document.selection) { // IE7
- return document.selection.createRange().text;
+ return document.selection.createRange().text.toString();
} else if (document.getSelection) { // others
return document.getSelection();
} else {
More information about the Laszlo-checkins
mailing list