On Mar 11, 7:34 am, "tradiate" <[EMAIL PROTECTED]> wrote:
> I've got a C++ XPCOM component that works great if I instantiate it
> from JavaScript by using the technique of:
> var myobj = Components.classes["my_contract_id"].
> createInstance(Components.interfaces[Components.interfaces.myInterface]);
>
> However, I'd like to attach this object to the Global so that I'll be
> able to instantiate it like this instead:
> var myobj = new MyObj();
>
> ...snip...
>
> So JS knows the object is there, but I'm missing something related to
> constructor-ness.
>
> Can anyone point me to examples of how this is done?

Try using the "JavaScript global constructor" category technique.
There is a code snippet here describing how to do it:
http://weblogs.mozillazine.org/weirdal/archives/017188.html

You can also look at Mozilla source code to see where it is done:
http://mxr.mozilla.org/seamonkey/

For example:
http://mxr.mozilla.org/seamonkey/source/browser/components/feeds/src/FeedWriter.js#1097

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to