This page describes how to create Custom (C++) Events that can Pass Data. Meaning that you can add extra parameters and query them. One example is lets say you want ff to perform an action whenever something happens, but depending of severity of that event you will react with a different severity. Ok, so that's a great example but work with me.
This is no easy task. In order to do this you must be able to do all of the following
- Download Mozilla Source Code
- Build Mozilla
- Creating Custom Firefox Extensions with the Mozilla Build System, this is the foundation for everything we'll do. I'll go over some (very little) of it so do this first then come back and do this tutorial.
What's In A Name
Despite whatever you may have heard in your english class there's a lot in a name. As of Bon Echo Alpha 2, if your do not start with "nsDOM" and their interfaces do not start with "nsIDOM" then you can forget about passing data. You will still be able to throw events but that is it.
You may have wondered why is it that you need to download (or check out) the source it's because you will have to modify the source. But wait does that mean my stuff won't work with anyone else's version of Firefox? Yes. Unless you get your patches into the trunk. Why isn't there a better way of doing this? That's a very good question.
The change you make here is really rather small but it is incredibly important. If you peruse nsIDOMClassInfo.h you'll find an enum named nsDOMClassInfoID. You'll want to add an entry to it. Your entry should be second last. The last one, eDOMClassInfoIDCount, is a counter. Your entry should look like this:
Here's the fun part: Above I mentioned that you must name your events as nsDOM, well here you want to put the other part of the name (e.g. if you have an event named nsDOMMyFirstEvent your nsDOMClassInfoID entry would be eDOMClassInfo_MyFirstEvent_id).
Added a few more macro calls:
- around line 1000:
NS_DEFINE_CLASSINFO_DATA(strkGoBack, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS)
- around line 2900:
DOM_CLASSINFO_MAP_BEGIN(strkGoBack, StrkIGoBack) DOM_CLASSINFO_MAP_ENTRY(StrkIGoBack)