Provides data about a DOM event.
Inheritance: System.EventArgs
        void nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
        {
            string type;
            using (nsAString str = new nsAString())
            {
                e.GetType(str);
                type = str.ToString();
            }

            GeckoDomEventArgs ea = null;

            switch (type)
            {
                case "keydown": OnDomKeyDown((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keyup": OnDomKeyUp((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;

                case "mousedown": OnDomMouseDown((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseup": OnDomMouseUp((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mousemove": OnDomMouseMove((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseover": OnDomMouseOver((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseout": OnDomMouseOut((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "click": OnDomClick(ea = new GeckoDomEventArgs(e)); break;
                case "submit": OnDomSubmit(ea = new GeckoDomEventArgs(e)); break;
            }

            if (ea != null && ea.Cancelable && ea.Handled)
                e.PreventDefault();
        }
 /// <summary>Raises the <see cref="DomSubmit"/> event.</summary>
 /// <param name="e">The data for the event.</param>
 protected virtual void OnDomSubmit(GeckoDomEventArgs e)
 {
     if (((GeckoDomEventHandler)this.Events[DomSubmitEvent]) != null)
         ((GeckoDomEventHandler)this.Events[DomSubmitEvent])(this, e);
 }
 /// <summary>Raises the <see cref="DomCompositionStart"/> event.</summary>
 /// <param name="e">The data for the event.</param>
 protected virtual void OnDomCompositionStart(GeckoDomEventArgs e)
 {
     if (((GeckoDomEventHandler)this.Events[DomCompositionStartEvent]) != null)
         ((GeckoDomEventHandler)this.Events[DomCompositionStartEvent])(this, e);
 }
Esempio n. 4
0
        /// <summary>
        /// An example event handler for the DomClick event.
        /// Prevents a link click from navigating.
        /// </summary>
        void StopLinksNavigating(object sender, GeckoDomEventArgs e)
        {
            if (sender != null && e != null && e.Target != null && e.Target.TagName != null)
            {
                GeckoElement clicked = e.Target;

                // prevent clicking on Links from navigation to the
                if (clicked.TagName == "A")
                {
                    e.Handled = true;
                    MessageBox.Show(sender as IWin32Window, String.Format("You clicked on Link {0}", clicked.GetAttribute("href")));
                }

            }
        }
        void nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
        {
            string type;
            using (nsAString str = new nsAString())
            {
                e.GetTypeAttribute(str);
                type = str.ToString();
            }

            GeckoDomEventArgs ea = null;

            switch (type)
            {
                case "keydown": OnDomKeyDown((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keyup": OnDomKeyUp((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keypress": OnDomKeyPress((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;

                case "mousedown": OnDomMouseDown((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseup": OnDomMouseUp((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mousemove": OnDomMouseMove((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseover": OnDomMouseOver((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseout": OnDomMouseOut((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "click": OnDomClick(ea = new GeckoDomEventArgs(e)); break;
                case "submit": OnDomSubmit(ea = new GeckoDomEventArgs(e)); break;
                case "compositionstart": OnDomCompositionStart(ea = new GeckoDomEventArgs(e)); break;
                case "compositionend": OnDomCompositionEnd(ea = new GeckoDomEventArgs(e)); break;
                case "contextmenu": OnDomContextMenu((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "DOMMouseScroll": OnDomMouseScroll((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "focus": OnDomFocus(ea = new GeckoDomEventArgs(e)); break;
            }

            if (ea != null && ea.Cancelable && ea.Handled)
                e.PreventDefault();
        }
 /// <summary>Raises the <see cref="LoadEvent"/> event.</summary>
 /// <param name="e">The data for the event.</param>
 protected virtual void OnLoad(GeckoDomEventArgs e)
 {
     if (((GeckoDomEventHandler)this.Events[LoadEvent]) != null)
         ((GeckoDomEventHandler)this.Events[LoadEvent])(this, e);
 }
 /// <summary>Raises the <see cref="DomDoubleClick"/> event.</summary>
 /// <param name="e">The data for the event.</param>
 protected virtual void OnDomDoubleClick(GeckoDomEventArgs e)
 {
     if (((GeckoDomEventHandler)this.Events[DomDoubleClickEvent]) != null)
         ((GeckoDomEventHandler)this.Events[DomDoubleClickEvent])(this, e);
 }
 /// <summary>Raises the <see cref="DomContentChangedEvent"/> event.</summary>
 /// <param name="e">The data for the event.</param>
 protected virtual void OnDomContentChanged(GeckoDomEventArgs e)
 {
     if (((GeckoDomEventHandler)this.Events[DomContentChangedEvent]) != null)
         ((GeckoDomEventHandler)this.Events[DomContentChangedEvent])(this, e);
 }
        void nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
        {
            string type;
            using (nsAString str = new nsAString())
            {
                e.GetTypeAttribute(str);
                type = str.ToString();
            }

            GeckoDomEventArgs ea = null;

            switch (type)
            {
                case "keydown": OnDomKeyDown((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keyup": OnDomKeyUp((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keypress": OnDomKeyPress((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;

                case "mousedown": OnDomMouseDown((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseup": OnDomMouseUp((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mousemove": OnDomMouseMove((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseover": OnDomMouseOver((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseout": OnDomMouseOut((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "click": OnDomClick(ea = new GeckoDomEventArgs(e)); break;
                case "dblclick": OnDomDoubleClick(ea = new GeckoDomEventArgs(e)); break;
                case "submit": OnDomSubmit(ea = new GeckoDomEventArgs(e)); break;
                case "compositionstart": OnDomCompositionStart(ea = new GeckoDomEventArgs(e)); break;
                case "compositionend": OnDomCompositionEnd(ea = new GeckoDomEventArgs(e)); break;
                case "contextmenu": OnDomContextMenu((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "DOMMouseScroll": OnDomMouseScroll((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "focus": OnDomFocus(ea = new GeckoDomEventArgs(e)); break;
                case "load": OnLoad(ea = new GeckoDomEventArgs(e)); break;
                case "change": OnDomContentChanged(ea = new GeckoDomEventArgs(e)); break;

                default:
                    Action<string> action;
                    if(_messageEventListeners.TryGetValue(type, out action))
                    {

                        action.Invoke(new GeckoDomMessageEventArgs((nsIDOMMessageEvent)e).Message);
                    }
                    break;
            }

            if (ea != null && ea.Cancelable && ea.Handled)
                e.PreventDefault();
        }