Watch the backlight?

Is it possible to use nsISelectionController to view when selection / selection is made?

I know that there are different areas of selection. I want to see when a user makes a selection in the default area visible in MXR - nsISelectionController Constants .

A view like addEventListener when you select a change, but in the text nodes of the document.

thank

0
events firefox-addon xpcom selection
Mar 06 '14 at 6:02
source share
1 answer

I found a solution, but it does not use nsIController, as @Neil recommended in the SO topic <HERE look at viewSource.js.

I am still interested in nsIController solution if I try to understand that it connects me.

So, here is how you observe the choice:

var mylis = { timeout: 0, notifySelectionChanged: function(doc, sel, reason) { if (!this.timeout) { this.timeout = setTimeout(function() { console.log('notifySelectionChanged','doc=',doc,'sel=',sel,'reason=',reason); mylis.timeout = 0; }, 1000); } } } gBrowser.contentWindow.getSelection().QueryInterface(Ci.nsISelectionPrivate).addSelectionListener(mylis); //gBrowser.contentWindow.getSelection().QueryInterface(Ci.nsISelectionPrivate).removeSelectionListener(mylis); 

the timeout is important because otherwise it will slow down the browser flow. you can see how you highlight it all gimicky. viewSource.js used 100 ms, so I would recommend doing this.

MXR - viewSource.js

0
Mar 06 '14 at 8:57
source share



All Articles