How to highlight word under mouse in TextArea?

182 views
Skip to first unread message

Yu

unread,
Nov 20, 2010, 1:20:26 AM11/20/10
to Google Web Toolkit
Hi,

I'd like to highlight the word under the mouse as the mouse pointer
move around in a TextArea. But I haven't found any API to do that?

Could you please help?

Thanks,

Yu

Gaurav Vaish

unread,
Nov 21, 2010, 9:44:21 AM11/21/10
to Google Web Toolkit
IMHO, there's no Javascript API to select only a part of text in text-
area... would be happy to be proven wrong.


--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.com

Nicolas Antoniazzi

unread,
Nov 21, 2010, 9:49:10 AM11/21/10
to google-we...@googlegroups.com
I do not know the low level functions for doing this, but it is possible. We use a tool called CodeMirror on our project. It is a rich text area with code parser and syntax highlight.
There are methods it the api to select portion of text.




2010/11/21 Gaurav Vaish <gaurav...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Gaurav Vaish

unread,
Nov 21, 2010, 10:11:02 AM11/21/10
to Google Web Toolkit
Hi Nicolas,

Fantastic reference.

And look at http://codemirror.net/jstest.html (search for "var" and
it's great).

Looking into the code, I found something of interest in js/editor.js
file.


--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.com


On Nov 21, 7:49 pm, Nicolas Antoniazzi <nicolas.antonia...@gmail.com>
wrote:
> I do not know the low level functions for doing this, but it is possible. We
> use a tool called CodeMirror on our project. It is a rich text area with
> code parser and syntax highlight.
> There are methods it the api to select portion of text.
>
> http://codemirror.net/
>
> <http://codemirror.net/>
>
> 2010/11/21 Gaurav Vaish <gaurav.va...@gmail.com>
>
> > IMHO, there's no Javascript API to select only a part of text in text-
> > area... would be happy to be proven wrong.
>
> > --
> > Happy Hacking,
> > Gaurav Vaish
> >http://www.mastergaurav.com
>
> > On Nov 20, 11:20 am, Yu <yfan...@gmail.com> wrote:
> > > Hi,
>
> > > I'd like to highlight the word under the mouse as the mouse pointer
> > > move around in a TextArea. But I haven't found any API to do that?
>
> > > Could you please help?
>
> > > Thanks,
>
> > > Yu
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

Thomas Broyer

unread,
Nov 21, 2010, 10:19:48 AM11/21/10
to Google Web Toolkit


On 21 nov, 15:44, Gaurav Vaish <gaurav.va...@gmail.com> wrote:
> IMHO, there's no Javascript API to select only a part of text in text-
> area... would be happy to be proven wrong.

setSelectionRange?
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/ValueBoxBase.html#setSelectionRange(int,
int)

The issue here is to "get the word under the mouse pointer".


Gaurav Vaish

unread,
Nov 21, 2010, 1:28:02 PM11/21/10
to Google Web Toolkit
A very ugly way (last resort) is to put each and every word under a
separate div. Duh me!


--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.com


On Nov 21, 8:19 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On 21 nov, 15:44, Gaurav Vaish <gaurav.va...@gmail.com> wrote:
>
> > IMHO, there's no Javascript API to select only a part of text in text-
> > area... would be happy to be proven wrong.
>
> setSelectionRange?http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g...,
Reply all
Reply to author
Forward
0 new messages