In article <9oi3jg$[EMAIL PROTECTED]>,
 "daniel park" <[EMAIL PROTECTED]> wrote:

> I would like to grab the selected region/text from the main content/browser
> window and display it on my sidebar. All I can think of is using the
> nsISelectionListener, but what would I add the listener to... I would like
> to grab the selected region along with it's offset and length within the
> browser document. Any suggestions???

You add a selection listener to the selection, which I believe
you can get via window.getSelection(). You can then QI to
nsISelectionPrivate (assuming you are in XUL), and call
add/removeSelectionListener.

Check out:

<http://lxr.mozilla.org/seamonkey/source/content/base/public/
nsISelectionPrivate.idl#67>

Be aware that the selection changed callbacks can get called
a lot. You don't want to do too much work in response to them.
You might want to use a timer to do work only after the selection
has not changed for some period of time.

Simon

-- 
          Simon Fraser   Entomologist
  [EMAIL PROTECTED]   http://people.netscape.com/sfraser/

Reply via email to