I got it for firefox. Dont know how it will behave for internet
explorer. Still experimenting with things... this might help somebody
else. Or me too...


// Gets the selection-start (anchor) node. It is where the cursor
should be
native Node getAnchorNode(IFrameElement frame)

/*-{

        return frame.contentWindow.getSelection().anchorNode;

}-*/;


// Gets the offset of selection start in the anchor node
native int getAnchorOffset(IFrameElement frame)

/*-{

        return frame.contentWindow.getSelection().selection.anchorOffset;

}-*/;


// Gets the selection-end (focus) node
native Node getFocusNode(IFrameElement frame)

/*-{

        return frame.contentWindow.getSelection().selection.focusNode;

}-*/;


// Gets the offset of selection end in focus node
native int getFocusOffset(IFrameElement frame)

/*-{

        return frame.contentWindow.getSelection().selection.focusOffset;

}-*/;


Now where you need, use these methods like this:

IFrameElement ife = IFrameElement.as(richTextArea.getElement());
Node anchorNode = getAnchorNode(ife);
...

Reference:
https://developer.mozilla.org/en/DOM/Selection
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/955bbb6d3da873e2/23ea5026dbfbb6f9

If someone could reply with Internet Explorer documentation link like
the above of mozilla, it would be great.

Omer Akhter

On Feb 18, 6:41 am, satya <[email protected]> wrote:
> RichTextArea does not provide a method to get the current cursor
> location.
>
> Sorry
> Satya
>
> On Feb 15, 8:22 am, Tóth Imre <[email protected]> wrote:
>
> > 2009/2/14 A Friend Of Yours <[email protected]>
>
> > > Got things working a little... could anyone tell me how to get the
> > > cursor location in a RichTextArea?
>
> > that is interest me as well.
>
> > > On Feb 14, 1:34 am, A Friend Of Yours <[email protected]> wrote:
> > > > Hello
>
> > > > I am working on a project where I need a (java) source code
> > > > highlighting editor. I searched everywhere but could not find any
> > > > solution that could work with GWT. There are solutions such as
> > > > codepress but dont work with GWT. Neither in this forum could I find
> > > > anything useful.
>
> > > > I was hoping if somebody could tell me what actually GWT does inside
> > > > RichTextArea to enable rich text editing so that I might be able to
> > > > make my own widget for this purpose.
>
> > > > I tried the RichTextArea, RichTextAreaImpl and all its child classes
> > > > but could not really get what they are playing with except that they
> > > > are using iframe somehow. (May be because I dont know javascript as
> > > > much as used there)
>
> > > > Thanks
>
> > > > Omer
>
> > --
> > Best Regards
> > Tóth Imre
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to