Re: [crx] How can I show a tooltip on any page when i double click on a work inside that page

1,121 views
Skip to first unread message

Boris Smus

unread,
Apr 10, 2011, 8:12:14 PM4/10/11
to khalil dureidy, Chromium-extensions
Hi Khalil,

You can get the currently selected word in standard Javascript. Try this article: http://www.webreference.com/js/column12/crossbrowser.html

As far as showing tooltips, you could write your own solution or use existing one. For example, http://craigsworks.com/projects/qtip/ 

- Boris

On Sat, Apr 9, 2011 at 2:55 PM, khalil dureidy <kdur...@gmail.com> wrote:
Hi,

I wrote a javascript code that run on any page when double click on
any work on that page it reads that word and show some info in a
tooltip
but I still dont know how to show this tooltip in my extension when i
double click on a word in the page.

Ex. Google Dictionary (by Google).

Regards,
Khalil Dureidy.

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


khalil dureidy

unread,
Apr 9, 2011, 5:55:46 PM4/9/11
to Chromium-extensions

Ren

unread,
Apr 21, 2011, 1:07:50 AM4/21/11
to Chromium-extensions
Hi Khalil,
Are you able to figure out how to do it?

I'm building a Chrome extension and want to do the same thing. When
user select something I want to pop-up a tooltip around the selection.
So my code needs to know the pixel location of the selection.

If you could share anything you know, it'll be very appreciated.
Thanks a lot.

Cheers,
Ren


On Apr 10, 7:55 am, khalil dureidy <kdure...@gmail.com> wrote:
> Hi,
>
> I wrote a javascript code that run on any page whendoubleclickon
> any work on that page it reads that word and show some info in a
> tooltip
> but I still dont know how to show this tooltip in my extension when idoubleclickon a word in the page.

Gildas

unread,
Apr 21, 2011, 2:24:55 PM4/21/11
to Chromium-extensions
Hi,

Did you try Element.getBoundingClientRect method [1] ?

[1] https://developer.mozilla.org/en/DOM/element.getBoundingClientRect

Boris Smus

unread,
Apr 21, 2011, 5:27:56 PM4/21/11
to Gildas, Chromium-extensions
You might also find this sample useful for getting the current selection from a Chrome extension: https://github.com/kurrik/chrome-extensions/tree/master/contentscript-selection

- Boris

Ren

unread,
Apr 27, 2011, 6:45:27 AM4/27/11
to Chromium-extensions
Thanks for your links guys, great example. I got it work now.

Hi Boris,
At the moment, the user has to select some text, and click my
extension icon to trigger my logic. I want my logic to be triggered as
soon as user select some text in any page.

At the moment, the only way I could figure out is to use 'content
script' to listen to 'mouseup' event on whole HTML document. However
it doesn't work on certain websites, such as Gmail. Gmail removed all
my registered listeners.

Are there any other alternatives that you can think of?

Cheers,
Ren


On Apr 22, 7:27 am, Boris Smus <s...@chromium.org> wrote:
> You might also find this sample useful for getting the current selection
> from a Chrome extension:https://github.com/kurrik/chrome-extensions/tree/master/contentscript...
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org.

PhistucK

unread,
Apr 27, 2011, 6:50:21 AM4/27/11
to Ren, Chromium-extensions
What about the "select" event?

PhistucK



To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

Ren

unread,
Apr 27, 2011, 7:17:05 AM4/27/11
to Chromium-extensions
Hi PhistucK,
There're two things I'm not sure about the 'select' event.
1. Is 'select' event supported by all elements? I know it's only
supported by <input text, password, and textarea in certain browsers.
2. If it's supported in Chrome, how do I bind this event? Do I bind it
to the 'document' object? What I want to achieve is a event handler
that's triggered whenever user select any text on the page.

Thanks a lot.
Ren

On Apr 27, 8:50 pm, PhistucK <phist...@gmail.com> wrote:
> What about the "select" event?
>
> ☆*PhistucK*

PhistucK

unread,
Apr 27, 2011, 7:40:57 AM4/27/11
to Ren, Chromium-extensions
Yeah, it seems that "select" is only triggered on specific elements.
You can, I guess, set a variable every time "selectstart" is triggered and check if that variable is set on "mouseup".
Maybe others have better ideas, I never really dealt with selection stuff.
PhistucK



To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

arthur

unread,
Apr 27, 2011, 5:38:22 PM4/27/11
to Ren, Chromium-extensions
.. However
> it doesn't work on certain websites, such as Gmail. Gmail removed all
> my registered listeners.
>
You could check this thread

https://groups.google.com/a/chromium.org/group/chromium-extensions/browse_thread/thread/90d6bbc61f8f798a?hl=en#

Arthur

Reply all
Reply to author
Forward
0 new messages