Re: add mouse listener
Sylvain Ferriol <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Message-ID | <-dSdnW5RpOFtHCXYnZ2dnUVZ_segnZ2d__13937.7326974229$1169719819$gmane$org@mozilla.org> |
Michal Ceresna wrote:
> On Wednesday 24 January 2007 3:16 pm, Sylvain Ferriol wrote:
>
>> i have no interface in nsIDOMDocument to register a listener
> you have to queryInterface the document to nsIDOMEventTarget
>
thanks
but nothing happened, my event listener is never called, this is my code:
nsIServiceManager serviceManager = mozilla.getServiceManager();
nsIAppStartup appStartup =
(nsIAppStartup)serviceManager.getServiceByContractID("@mozilla.org/toolkit/app-startup;1",
nsIAppStartup.NS_IAPPSTARTUP_IID);
nsIWindowCreator windowCreator =
(nsIWindowCreator)appStartup.queryInterface(nsIWindowCreator.NS_IWINDOWCREATOR_IID);
nsIWindowWatcher windowWatcher =
(nsIWindowWatcher)serviceManager.getServiceByContractID("@mozilla.org/embedcomp/window-watcher;1",
nsIWindowWatcher.NS_IWINDOWWATCHER_IID);
windowWatcher.setWindowCreator(windowCreator);
nsIDOMWindow win = windowWatcher.openWindow(null, url, "mywindow",
"chrome,resizable,centerscreen,width=400,height=300", null);
windowWatcher.setActiveWindow(win);
nsIDOMDocument document = win.getDocument();
nsIDOMEventTarget eventTarget =
(nsIDOMEventTarget)document.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
EventListener eventListener = new EventListener();
eventTarget.addEventListener("click", eventListener, false);
appStartup.run();
> best regards,
> Michal