This class is a wrapper to the underlying IDOMEventListner. It re-raises a C# event with apropriate event args.
Inheritance: nsIDOMEventListener
Exemple #1
0
        /// <summary>
        /// Remove  C# listner from the xpcom listner.
        /// </summary>
        /// <param name="Type">The name of the eventtype, for e.g 'MyCustomEvent'. This must be the same as the EventName in the JavaScript.</param>
        /// <param name="Handler">The handler for this event</param>
        public void RemoveEventListener(string Type, EventHandler <DOMJSONStringEventArgs> Handler)
        {
            nsIDOMEventTarget target  = oDomWindow as nsIDOMEventTarget;
            nsAString         strType = oEventTypes[Handler.Method.GetHashCode()] as nsAString;

            RouteEventHandler route = oEventListeners[Handler.Method.GetHashCode()] as RouteEventHandler;

            target.RemoveEventListener(strType, route, false);

            oEventListeners.Remove(Handler.Method.GetHashCode());
            oEventTypes.Remove(Handler.Method.GetHashCode());
        }
        /// <summary>
        /// Add a C# listner to the xpcom listner. This is done by wrappinig the xpcom event.
        /// </summary>
        /// <param name="Type">The name of the eventtype, for e.g 'MyCustomEvent'. This must be the same as the EventName in the JavaScript.</param>
        /// <param name="Handler">The handler for this event</param>
        public void AddEventListener(string Type, EventHandler<DOMJSONStringEventArgs> Handler)
        {
            RouteEventHandler Listener = new RouteEventHandler(Handler);
            if (oEventListeners.ContainsKey(Handler.Method.GetHashCode()) == true && oEventTypes.ContainsKey(Handler.Method.GetHashCode()))
            {
                oEventListeners.Remove(Handler.Method.GetHashCode());
                oEventTypes.Remove(Handler.Method.GetHashCode());
            }

            oEventListeners.Add(Handler.Method.GetHashCode(), Listener);

            nsAString nsType = new nsAString(Type);
            oEventTypes.Add(Handler.Method.GetHashCode(), nsType);

            (oDomWindow as nsIDOMEventTarget).AddEventListener(nsType, Listener, false, false, 0);
        }
Exemple #3
0
        /// <summary>
        /// Add a C# listner to the xpcom listner. This is done by wrappinig the xpcom event.
        /// </summary>
        /// <param name="Type">The name of the eventtype, for e.g 'MyCustomEvent'. This must be the same as the EventName in the JavaScript.</param>
        /// <param name="Handler">The handler for this event</param>
        public void AddEventListener(string Type, EventHandler <DOMJSONStringEventArgs> Handler)
        {
            RouteEventHandler Listener = new RouteEventHandler(Handler);

            if (oEventListeners.ContainsKey(Handler.Method.GetHashCode()) == true && oEventTypes.ContainsKey(Handler.Method.GetHashCode()))
            {
                oEventListeners.Remove(Handler.Method.GetHashCode());
                oEventTypes.Remove(Handler.Method.GetHashCode());
            }

            oEventListeners.Add(Handler.Method.GetHashCode(), Listener);

            nsAString nsType = new nsAString(Type);

            oEventTypes.Add(Handler.Method.GetHashCode(), nsType);

            (oDomWindow as nsIDOMEventTarget).AddEventListener(nsType, Listener, false, false, 0);
        }