Hello everyone I must make a correction.
initEvent works fine. It is dispatchEvent that is causing the trouble. I tried to send the event from Javascript and from C++ and I get the same result 0x80070057 meaning NS_ERROR_ILLEGAL_VALUE as an exception in JS and return code from dispatchEvent in C++. Sorry for the mix-up. -----Original Message----- From: dev-embedding-bounces+walter.fettich=lasting...@lists.mozilla.org [mailto:dev-embedding-bounces+walter.fettich=lasting...@lists.mozilla.org] On Behalf Of Walter Fettich Sent: Tuesday, January 20, 2009 6:45 PM To: [email protected] Subject: Why can't I send my custom event? Hello dear mozillaners. Okay so I created my own event component for XPCOM so that I can send parameters with an event. What I basically did is this: - Create a new XPCOM component as specified on this site( http://www.iosart.com/firefox/xpcom ) and other resources. - I derived my component class from nsIDOMEvent interface. - In the constructor I create an event object using the method nsIDocumentEvent::CreateEvent(..) and all nsIDOMEvent methods are redirected to that object's pointer. - I registered the component with XPCOM and it is visible from Javascript and C++ meaning I can create an instance of my component. The Problem is that calling initEvent("eventName",true,true) fails with return code 0x80070057 meaning NS_ERROR_ILLEGAL_VALUE. This is how I dispatch the event in Javascript: var cid = "@mydomain.com/Whatever/DOMCustomEvent;1"; if (!(cid in Components.classes)) { alert("component not found"); return; } var ev = Components.interfaces.nsIDOMEvent; var obj = Components.classes[cid].createInstance(ev); obj.initEvent("myevent", true, true); window.dispatchEvent(obj); This fails unfortunately at initEvent. I ran out of ideas on what the problem might be and so I turn to any knowledgeable and kind-hearted soul on this forum. Thank you very much. _______________________________________________ dev-embedding mailing list [email protected] https://lists.mozilla.org/listinfo/dev-embedding _______________________________________________ dev-embedding mailing list [email protected] https://lists.mozilla.org/listinfo/dev-embedding
