"Working with text selection"

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

"Working with text selection"

Alexander Back
Hi Chris,

I also post our conversation to the list to share the infos. See my
comments below.

Chris Banford wrote:

> Hi Alex,
>>> From my experience with our Tools, it would be great if one could
>>> 'easily' move the Caret to the Start, End or any given position in a
>>> text block.
>> > Not sure if this is already part of your plan, but thought a little
>> feedback might be nice ;-)
>> First of all the Selection/Range classes are laid out to work with all
>> kind of nodes (element nodes, textfield/textarea and text nodes), but
>> for the now available (basic) implementation we focused on the things
>> we currently need for the framework classes (namely "TextField" and
>> "TextArea" widgets).
>> When you mention "text block" do you mean a bunch of text nodes or a
>> textarea element? For the latter the Selection API is capable of
>> setting the caret by using the "set" method on the textarea element.
>> --snip--
>> // set the caret to the start
>> qx.bom.Selection.set(document.getElementById("myTextArea", 0, 0);
>> --snip--
>> If you talking about a normal text block, it is a bit more difficult.
>> You can only place a caret if the whole document is in  the so-called
>> "designMode" (this is e.g. used for the HtmlArea widget). Only IE does
>> allow to make specific elements editable. So setting a caret on a
>> normal text block won't be a thing easy to achieve at the moment.
> Yes, I did mean the difficult one (of course!) :-) .
Yes, I could have guessed that one :-)

> Its not something that I've delved into at all, but had followed the
> discussion of this on the YUI mailing list. There was talk of being able
> to save a caret position in design mode by adding a temp span marker,
> and then removing it again later (and somehow getting the caret to wind
> up there). Getting the caret to go to the start or end of the contents
> in design mode would also be great, if its possible. Dav Glass has done
> quite a good job with his Rich Text Editor on YUI and its one of the
> most important bits of our CMS.
You know already the HtmlArea [0] widget? It is a Rich Text Editor based
on qooxdoo 0.7.x and comparable to the YUI widget. The new Selection API
is however only available for the new upcoming 0.8 version, but we
already started to port the HtmlArea to 0.8 (not finished yet).
So in the future the HtmlArea will make use of the new Selection API and
in the course of this the Selection API will expand and maybe there will
be support for the positioning of the caret.

> Anyways, this was just an idea for a possible future feature - nothing
> that would be a deal breaker.
Thanks for this idea. It is always good to hear what features are needed
in order to build a cool widget. I'll add this feature request to our
bugzilla to not loose this one :-)


[0] http://qooxdoo.org/documentation/contrib/HtmlArea

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
qooxdoo-devel mailing list
[hidden email]