public static DomEventArgs Create(nsIDOMEvent ev) { var type = nsString.Get(ev.GetTypeAttribute).ToLowerInvariant(); // search by name and create child class wrappers switch (type) { case "keydown": case "keyup": case "keypress": return(DomKeyEventArgs.Create((nsIDOMKeyEvent)ev)); case "mousedown": case "mouseup": case "mousemove": case "mouseover": case "mouseout": case "contextmenu": return(DomMouseEventArgs.Create((nsIDOMMouseEvent)ev)); case "dommousescroll": return(DomMouseScrollEventArgs.Create((nsIDOMMouseScrollEvent)ev)); case "dragstart": case "dragenter": case "dragover": case "dragleave": case "drag": case "drop": case "dragend": return(DomDragEventArgs.Create((nsIDOMDragEvent)ev)); case "hashchange": return(DomHashChangeEventArgs.Create(( nsIDOMHashChangeEvent )ev)); } // search by type if (ev is nsIDOMUIEvent) { return(DomUIEventArgs.Create((nsIDOMUIEvent)ev)); } if (ev is nsIDOMMessageEvent) { return(DomMessageEventArgs.Create((nsIDOMMessageEvent)ev)); } if (ev is nsIDOMSVGEvent) { return(DomSvgEvent.Create(( nsIDOMSVGEvent )ev)); } return(new DomEventArgs(ev)); }
/// <summary> /// Prevent a CTRL+V pasting when we have the Paste button disabled, e.g. when pictures are on the clipboard. /// Also handle CTRL+N creating a new page on Linux/Mono. /// </summary> void OnDomKeyPress(object sender, DomKeyEventArgs e) { Debug.Assert(!InvokeRequired); const uint DOM_VK_INSERT = 0x2D; //enhance: it's possible that, with the introduction of ckeditor, we don't need to pay any attention //to ctrl+v. I'm doing a hotfix to a beta here so I don't want to change more than necessary. if ((e.CtrlKey && e.KeyChar == 'v') || (e.ShiftKey && e.KeyCode == DOM_VK_INSERT)) //someone was using shift-insert to do the paste { if (_pasteCommand==null /*happened in calendar config*/ || !_pasteCommand.Enabled) { Debug.WriteLine("Paste not enabled, so ignoring."); e.PreventDefault(); } //otherwise, ckeditor will handle the paste } // On Windows, Form.ProcessCmdKey (intercepted in Shell) seems to get ctrl messages even when the browser // has focus. But on Mono, it doesn't. So we just do the same thing as that Shell.ProcessCmdKey function // does, which is to raise this event. if (SIL.PlatformUtilities.Platform.IsMono && ControlKeyEvent != null && e.CtrlKey && e.KeyChar == 'n') { Keys keyData = Keys.Control | Keys.N; ControlKeyEvent.Raise(keyData); } }
/// <summary>Raises the <see cref="DomKeyPress"/> event.</summary> /// <param name="e">The data for the event.</param> protected virtual void OnDomKeyPress(DomKeyEventArgs e) { var evnt = (EventHandler<DomKeyEventArgs>)Events[DomKeyPressEvent]; if (evnt != null) evnt(this, e); }
/// <summary>The browser on dom key down.</summary> /// <param name="sender">The sender.</param> /// <param name="domKeyEventArgs">The <see cref="DomKeyEventArgs"/> instance containing the event data.</param> private void BrowserOnDomKeyDown(object sender, DomKeyEventArgs domKeyEventArgs) { try { switch (domKeyEventArgs.KeyCode) { case (uint)Keys.F5: lock (this.reloadLockObject) { this.DocumentCookies.Clear(); this.browser.Reload(); } return; case (uint)Keys.F4: if (!domKeyEventArgs.AltKey) { return; } this.CloseBrowser(); return; case (uint)Keys.F1: { var stringBuilder = new StringBuilder(); var num = 0; var allScreens = Screen.AllScreens; foreach (var screen in allScreens) { stringBuilder.AppendLine(string.Format("Screen #{0} ({1})", num++, screen.DeviceName)); stringBuilder.AppendLine("Primary display: " + screen.Primary); stringBuilder.AppendLine(string.Format("Display resolution: {0} x {1}", screen.Bounds.Width, screen.Bounds.Height)); stringBuilder.AppendLine(string.Format("Position: x={0}, y={1}", screen.Bounds.Left, screen.Bounds.Top)); stringBuilder.AppendLine(string.Empty); } MessageBox.Show(stringBuilder.ToString(), Resources.screenInfo_DE_AT, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } return; case (uint)Keys.S: if (!domKeyEventArgs.CtrlKey) { return; } Bootstrapper.GetInstance<IBrowserConfiguration>().Save(); return; case (uint)Keys.BrowserFavorites: case (uint)Keys.Add: if (!domKeyEventArgs.CtrlKey) { return; } this.ZoomIn(); break; case (uint)Keys.VolumeMute: case (uint)Keys.Subtract: if (!domKeyEventArgs.CtrlKey) { return; } this.ZoomOut(); break; case (uint)Keys.NumPad0: case (uint)Keys.D0: if (!domKeyEventArgs.CtrlKey) { return; } this.ResetZoom(); break; } } catch (Exception exception) { Logger.Warn(exception); } }
/// <summary>Raises the <see cref="DomKeyPress"/> event.</summary> /// <param name="e">The data for the event.</param> protected virtual void OnDomKeyPress(DomKeyEventArgs e) { RaiseEvent(new RoutedEventArgs(DomKeyPressEvent, e)); }
/// <summary>Raises the <see cref="DomKeyUp"/> event.</summary> /// <param name="e">The data for the event.</param> protected virtual void OnDomKeyUp(DomKeyEventArgs e) { var evnt = (EventHandler<DomKeyEventArgs>)_eventList[DomKeyUpEvent]; if (evnt != null) evnt(this, e); }