[Laszlo-dev] For Review: Change 20090603-hqm-U Summary: fix for text selection in DHTML
André Bargull
andre.bargull at udo.edu
Sat Jun 6 07:25:33 PDT 2009
> + LzKeyboardKernel.js: Instead of cancelling a mouse event completely,
> just cancel bubbling. [...]
Mouse events are no longer passed to
"LzKeyboardKernel.__keyboardEvent(..)", so it shouldn't be necessary to
change this code.
> + LzSprite.js: only toggle the focus in focus_on_mouseover quirk when
> there is some text selected.
"window.getSelection()" returns always a Selection object [1], so the
test for "getSelectedText() == null" will always yield false. You need
to call "toString()" on the Selection object to get the currently
selected text and then test for `getSelectedText() != ""`. (Same for
"document.selection.createRange().text": it returns an empty string if
nothing is selected, so the test `!= null` doesn't work as intended, too.)
> +
> + var browser = lz.embed.browser;
> }
>
> + // check source.owner of event, see if textfield and selectable, then don't cancel event
> +
These changes for LzMouseKernel.js aren't intended, are they?
And there is a bug in Firefox/Safari:
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
(But the <img> selection also occurs in other cases for Firefox, so I
think we want to set "-moz-user-select:none !important;" for <img>,
maybe also for Safari..)
And one bug in IE:
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
Apparently global onselectstart and ondrag were canceled in
"LzInputTextSprite.js" to avoid this behaviour, cf. [3].
PS:
I cannot use the tab-key in Safari (Win), did anybody else notice?
[1] https://developer.mozilla.org/En/DOM/Selection
[2] /examples/components/component_sampler.lzx?lzr=dhtml&debug=true
[3]
http://www.ditchnet.org/wp/2005/06/15/ajax-freakshow-drag-n-drop-events-2/#comment-160
On 6/4/2009 4:56 AM, Henry Minsky wrote:
> Change 20090603-hqm-U by hqm at badtzmaru.home on 2009-06-03 22:27:28 EDT
> in /Users/hqm/openlaszlo/trunk5
> for http://svn.openlaszlo.org/openlaszlo/trunk
>
> Summary: fix for text selection in DHTML
>
> New Features:
>
> Bugs Fixed: LPP-8200
>
> Technical Reviewer: max
> QA Reviewer: andre
> Doc Reviewer: (pending)
>
> Documentation:
>
> Release Notes:
>
> Details:
>
> + LzSprite.js: only toggle the focus in focus_on_mouseover quirk when
> there is some text selected.
>
> + LzKeyboardKernel.js: Instead of cancelling a mouse event completely,
> just cancel bubbling. This lets the div handle the event, and allows
> text selection to work, but should disable it from propagating to
> global handlers.
>
> + LzMouseKernel.js: don't cancel event with keyCode == 0 entirely, just
> cancel bubbling.
>
> + LzTextSprite.js: use correct CSS properties for toggling
> selectability, in Safari
>
> + LzInputTextSprite.js: do not bind the global document.onselectstart
> handler, that prevents
> text selection from working in some browsers
>
> + LzText.lzs: add the 'onselectable' event, not required for this
> patch, but I noticed it was missing when writing a test case
>
> Tests:
>
> + added lpp-8200.lzx test, try selecting a region in each the text
> fields, except for the last (non-selectable) one.
>
> + text selection should work in DHTML on selectable text or input text, all
> browsers
>
> + NOTE: there is a bug in IE7 text selection [maybe related to
> (LPP-8249) "IE7 DHTML text letter spacing looks bad"], where in the
> test case lpp-8200, if you try to drag the mouse to select the text in
> the <text> view which says "This is selectable text", you cannot use
> the mouse to select the last word ('text'). I think that maybe the
> letter spacing setting causes the browser to miscalulate the text
> width?
>
> Files:
> A test/lfc/lpp-8200.lzx
> M WEB-INF/lps/lfc/kernel/dhtml/LzKeyboardKernel.js
> M WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
> M WEB-INF/lps/lfc/kernel/dhtml/LzTextSprite.js
> M WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js
> M WEB-INF/lps/lfc/kernel/dhtml/LzInputTextSprite.js
> M WEB-INF/lps/lfc/views/LzText.lzs
>
> Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20090603-hqm-U.tar
>
More information about the Laszlo-dev
mailing list