Prompt/Cursor interface ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Prompt/Cursor interface ?

Antônio Gomes-2
Hi there,

I'd like to make some manual changes at the cursor/prompt position
inside a html form (specifically on /nsIDOMHTMLTextAreaElement/ and
/nsIDOMHTMLInputElement/ objects. I do have these objects in hands
already, and I'm also able to modify their content according to my
needs, like appending, deleting text inside html forms (via
dom/public/idl/html/nsIDOMHTMLInputElement.idl and
/content//html/content/src/nhHTMLInputElement.cpp setValue methods usage).

Now, I'm wondering what interfaces or methods enable the handling of the
position of the cursor inside a form.

thanks

ps: by cursor (or prompt) I meant the "thing" blinking when I input
object has the focus :)
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: Prompt/Cursor interface ?

Martin Honnen-3
Antônio Gomes wrote:


> I'd like to make some manual changes at the cursor/prompt position
> inside a html form (specifically on /nsIDOMHTMLTextAreaElement/ and
> /nsIDOMHTMLInputElement/ objects.

> ps: by cursor (or prompt) I meant the "thing" blinking when I input
> object has the focus :)

It is called the caret usually, with Mozilla for text input and textarea
controls there is a method
   setSelectionRange(selectionStart, selectionEnd)
exposed to set the text selection and the caret. If you simply want to
set the caret you would do e.g. (JavaScript syntax)
   textareaElement.setSelectionRange(5, 5)
If you want to read out the current text selection and/or caret position
you can read out properties
   selectionStart
   selectionEnd
See
<http://xulplanet.com/references/objref/HTMLTextAreaElement.html#method_setSelectionRange>

Interface is here:
<http://www.xulplanet.com/references/xpcomref/ifaces/nsIDOMNSHTMLTextAreaElement.html>

--

        Martin Honnen
        http://JavaScript.FAQTs.com/
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout