Hi Greg,
On Monday April 12 2010 17:43:46 Greg Beaver wrote:
> I'm trying to expand upon the HtmlArea example from the demo browser so
> that when the user has the cursor in a link and clicks the link button,
> it extracts the existing link and displays it in the text box, and then
> replaces the old one with the new one. This code:
>
> var test = this.getRange();
> if (test.startContainer.parentNode.nodeName == "A") {
> var textField = new
> qx.ui.form.TextField(test.startContainer.parentNode.attributes[0].firstChil
> d.data); } else {
> var textField = new qx.ui.form.TextField("http://");
> }
>
> works some of the time, but is extremely brittle/erratic. When one
> double-clicks a link to select a word, the <span> element containing the
> link is returned as startContainer. If one click-drags to select some
> of the letters in the link, the <a> element is returned as
> startContainer. If one click-drags to select all of the letters,
> sometimes the <a> element is returned, and sometimes the <span>
> element. It seems to differ based on whether the mouse drags a few
> pixels past the edge of the first letter or not.
>
> Does anyone have any ideas on how to deal with this frustratingly
> inconsistent behavior, or have a better way to detect a link under the
> cursor or in selected text?
Have you already tried the "getFocusNode" method of the HtmlArea? Maybe this
helps you further.
And as a more general note: retrieving the selection/currently selected node
in a cross-browser way is a difficult thing. Every browser/rendering engine has
its own pitfalls.
cheers,
Alex
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel