Jeremy Gentile wrote:
How does one go about setting up a JavaScript event handler for a XPCOM
component?   I would like for my XPCOM to generate events which can be
observed and acted upon by a JS function.

ActiveX uses the colon-colon syntax (see below).  Is there something similar
in XPCOM?

syntax in IE:
myObj = new ActiveXObject("MyObjectID");
function myObj::onEvent(i_event)
{
    alert("ActiveX event fired: " + i_event);
}

1) Is there a interface that need to be implemented by the XPCOM component
similar to ActiveX's IConnectionPoint interface?

2) Can it done by passing a JS function pointer to the XPCOM component to be
stored for later callbacks?  If so, are there any XPCOM examples of this?


Thanks in advance,

Jeremy



Without me knowing too much regarding syntax/methods, see have a JS object implement nsIObserver and pass that to your XPCOM function and have you XPCOM function send observe messages which your observer can figure out.


That is roughly how I have seen it used, personally... Though there are others here who can give you better explanation on how to do this, and I may be wrong in a step or two in that description.

My words are merely a very rough guide as a place to look into, if you'd rather look now than later, not an actual solution as I dont feel confident enough in my words to say such.

~Justin Wood (Callek)
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to