Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] swt browser

Hy guys,
I'm trying to implement the interface nsISelectionListener for detecting the current selected tag in the swt browser ( with DesignMode set to on ).
    nsIWebBrowser  webBrowser  ;
    nsIDOMWindow   webWindow   ;
    nsIDOMDocument webDocument ;

    nsISelectionListener tag_selection_listener = new nsISelectionListener()
    {

        @Override
        public void notifySelectionChanged(nsIDOMDocument doc, nsISelection sel, short reason)
        {
            System.out.println("selected tag = ['" + sel.getFocusNode().getNodeName() + "']" );
        }

        @Override
        public nsISupports queryInterface(String arg0)
        {
             //return this;
            return null;
        }
    };

    private void initSelectionListener()
    {
       webBrowser   = (nsIWebBrowser)browser.getWebBrowser();
       webWindow   = webBrowser.getContentDOMWindow();
       webDocument = webWindow.getDocument();
       webBrowser.addWebBrowserListener( tag_selection_listener, nsISelectionListener.NS_ISELECTIONLISTENER_IID );
    }

but nothing happens. What am I doing wrong?  Is there any other method to get the current focused tag?
I have xulrunner 1.8.1.3 on windows.


Don't let your dream ride pass you by. Make it a reality with Yahoo! Autos.

Back to the top