Hi Xulei,

I think you can use
nsISelectionPrivate::addSelectionListener [1]. You can get
nsISelectionPrivate through QueryInterface on nsISelection,
which you can get from nsIEditor.

Cheers,
Jim

[1]
http://mxr.mozilla.org/mozilla-central/source/content/base/public/nsISelectionPrivate.idl#52


On 8/28/13 5:24 AM, "Yuan Xulei(袁徐磊)" wrote:
> Hi all,
> 
> I'm implementing b2g keyboard/IME api and encounter a problem
> with the selection range observing.
> 
> We want to monitor the cursor position or selection range
> changes
> in current input element, which is a text input field or a
> content
> editable element receiving user's input. The cursor position
> or the
> selection range can be changed by
> 1) key events generated by virtual keyboard,
> 2) js code,
> 3) mouse events triggered by user.
> 
> Currently we listen a pile of events(mousedown, mouseup,
> input...)
> to check if the selection range has been changed. It is
> inefficient
> and error prone.
> 
> I wonder if there is a way to monitor the selection range
> changes
> from chrome js.
> 
> Could anyone give me a clue?
> 
> Thanks.
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to