private void AssertMapping(KeyState keyState, string text, KeyModifiers modifiers = KeyModifiers.None) { VimKeyData vimKeyData; Assert.True(_keyStateToVimKeyDataMap.TryGetValue(keyState, out vimKeyData)); Assert.Equal(text, vimKeyData.TextOptional); Assert.Equal(modifiers, vimKeyData.KeyInputOptional.KeyModifiers); }
public int RegisterHotkey(Keys key, KeyModifiers keyflags) { UInt32 hotkeyid = Win32.GlobalAddAtom(System.Guid.NewGuid().ToString()); Win32.RegisterHotKey((IntPtr)hWnd, hotkeyid, (UInt32)keyflags, (UInt32)key); keyIDs.Add(hotkeyid, hotkeyid); return (int)hotkeyid; }
public HotKeyEventArgs(IntPtr hotKeyParam, IntPtr wParam) { uint param = (uint)hotKeyParam.ToInt64(); Key = (Keys)((param & 0xffff0000) >> 16); Modifiers = (KeyModifiers)(param & 0x0000ffff); this.ID = (int)wParam; }
/// <summary> /// Initializes a new instance of the <see cref="FreezingArcher.Input.KeyboardInput"/> class. /// </summary> /// <param name="key">Key.</param> /// <param name="scancode">Scancode.</param> /// <param name="action">Action.</param> /// <param name="modifier">Modifier.</param> public KeyboardInput (Key key, int scancode, KeyAction action, KeyModifiers modifier) { Key = key; Scancode = scancode; Action = action; Modifier = modifier; }
public PencilKeyInfo(Pencil.Gaming.Key key, int scancode, KeyAction action, KeyModifiers modifiers) { Key = key; Scancode = scancode; Action = action; Modifiers = modifiers; }
public void RegisterHotKey(KeyModifiers keyModifiers, uint key) { if(hotKeySet) UnregisterHotKey(); hotKeySet = User32_RegisterHotKey(Handle, 100, keyModifiers, key); }
public static int RegisterHotKey(Keys key, KeyModifiers modifiers) { _windowReadyEvent.WaitOne(); int id = System.Threading.Interlocked.Increment(ref _id); _wnd.Invoke(new RegisterHotKeyDelegate(RegisterHotKeyInternal), _hwnd, id, (uint)modifiers, (uint)key); return id; }
public GlobalHotKey(KeyModifiers modifiers, Keys key) { if (!RegisterHotKey(this.Handle, ID, modifiers, key)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } }
private void VerifyConvert(VSConstants.VSStd2KCmdID cmd, KeyModifiers modifiers, KeyInput ki, EditCommandKind kind) { EditCommand command; Assert.True(OleCommandUtil.TryConvert(VSConstants.VSStd2K, (uint)cmd, IntPtr.Zero, modifiers, out command)); Assert.Equal(ki, command.KeyInput); Assert.Equal(kind, command.EditCommandKind); }
public HotKey(int id, KeyModifiers modifiers, Keys key, EventHandler<HotKeyEventArgs> genericHandler) { this.Id = id; this.Modifiers = modifiers; this.Keys = key; this.Handler = null; this.GenericHandler = genericHandler; }
public HotKey(int _keyID, Keys _key, KeyModifiers _modifier, EventHandler hotKeyPressed) { keyID = _keyID; HotKeyPressed = hotKeyPressed; key = _key; modifier = _modifier; Start(); }
public static extern bool RegisterHotKey( IntPtr hWnd, int id, KeyModifiers fsModifiers, Keys vk );
internal static KeyInput CreateKeyInput( VimKey key = VimKey.NotWellKnown, KeyModifiers mod = KeyModifiers.None, char? c = null) { return new KeyInput( key, mod, c.HasValue ? FSharpOption<char>.Some(c.Value) : FSharpOption<char>.None); }
public static extern bool RegisterHotKey( //要定义热键的窗口的句柄 IntPtr hWnd, //定义热键ID(不能与其它ID重复) int id, //标识热键是否在按Alt、Ctrl、Shift、Windows等键时才会生效 KeyModifiers fsModifiers, //定义热键的内容 Keys vk );
public Hotkey(IntPtr handle, int id, KeyModifiers modifiers, Keys key) { if (key == Keys.None || modifiers == KeyModifiers.None) throw new Exception(); Handle = handle; ID = id; Modifiers = modifiers; Key = key; RegisterHotKey(); Application.AddMessageFilter(this); }
/// <summary> /// Registers a hot key in the system. /// </summary> /// <param name="modifier">The modifiers that are associated with the hot key.</param> /// <param name="key">The key itself that is associated with the hot key.</param> /// <returns>Hot key ID</returns> public int RegisterHotKey(KeyModifiers modifier, Keys key) { // increment the counter. currentId = currentId + 1; // register the hot key. if (!RegisterHotKey(window.Handle, currentId, (uint)modifier, (uint)key)) { throw new InvalidOperationException("Couldn’t register the hot key."); } return currentId; }
internal static bool TryConvert(Guid commandGroup, uint commandId, IntPtr pVariableIn, KeyModifiers modifiers, out EditCommand command) { KeyInput keyInput; EditCommandKind kind; if (!TryConvert(commandGroup, commandId, pVariableIn, out keyInput, out kind)) { command = null; return false; } keyInput = KeyInputUtil.ApplyModifiers(keyInput, modifiers); command = new EditCommand(keyInput, kind, commandGroup, commandId); return true; }
/// Initializes a new instance of the <see cref="HotKey"/> by specific name, modifiers, and key. /// <param name="name">A <see cref="string"/> to identify the system hot key.</param> /// <param name="modifiers">Modify keys (Shift, Ctrl, Alt, and/or Windows Logo key).</param> /// <param name="key">Key code.</param> public HotKey(string name, KeyModifiers modifiers, Keys key) { if (name == null) { throw new ArgumentNullException("name"); } if (key == Keys.None) { throw new ArgumentException("key cannot be Keys.None. Must specify a key for the hot key.", "key"); } _name = name; _modifiers = modifiers; _key = key; }
// TODO: UnsubscribeListener() // private void OnKeyDown(object sender, KeyboardKeyEventArgs keyboardKeyEventArgs) { List<KeyListener> listeners; //KeyModifiers mods = keyboardKeyEventArgs.Modifiers; // note that this always returns 0, probably a bug in openTK KeyModifiers mods = new KeyModifiers(); mods = mods | (keyboard[Key.AltLeft] || keyboard[Key.AltRight] ? KeyModifiers.Alt : 0); mods = mods | (keyboard[Key.ShiftLeft] || keyboard[Key.ShiftRight] ? KeyModifiers.Shift : 0); mods = mods | (keyboard[Key.ControlLeft] || keyboard[Key.ControlRight] ? KeyModifiers.Control : 0); Listeners.TryGetValue(keyboardKeyEventArgs.Key, out listeners); if (listeners != null) { for (int i = 0; i < listeners.Count; i++) { listeners[i](mods); } } }
public HotKeyRegister(IntPtr handle, int id, KeyModifiers modifiers, Keys key) { if (key == Keys.None || modifiers == KeyModifiers.None) { throw new ArgumentException("键或者编辑器不能为空。"); } this.Handle = handle; this.ID = id; this.Modifiers = modifiers; this.Key = key; RegisterHotKey(); // 添加一个消息过滤器来监督窗体信息,因为它们是由目标选择路径的。 Application.AddMessageFilter(this); }
internal static bool TryConvert(Guid commandGroup, uint commandId, IntPtr pVariableIn, KeyModifiers modifiers, out EditCommand command) { KeyInput keyInput; EditCommandKind kind; bool isRawText; if (!TryConvert(commandGroup, commandId, pVariableIn, out keyInput, out kind, out isRawText)) { command = null; return false; } // When raw text is provided it already includes the active keyboard modifiers. Don't reapply them // here else it can incorrectly modify the provided character. if (!isRawText && keyInput != KeyInput.DefaultValue) { keyInput = KeyInputUtil.ApplyModifiers(keyInput, modifiers); } command = new EditCommand(keyInput, kind, commandGroup, commandId); return true; }
Key TranslateKey(int key, out KeyModifiers mods) { int k = MathHelper.Clamp((int)key, 0, KeyMap.Length); Key result = KeyMap[k]; mods = 0; mods |= (result == Key.AltLeft || result == Key.AltRight) ? KeyModifiers.Alt : 0; mods |= (result == Key.ControlLeft || result == Key.ControlRight) ? KeyModifiers.Control : 0; mods |= (result == Key.ShiftLeft || result == Key.ShiftRight) ? KeyModifiers.Shift : 0; return KeyMap[k]; }
internal void SetKey(Key key, uint scancode, KeyModifiers mods, bool pressed) { if (state[key] != pressed || KeyRepeat) { // limit scancode to 8bits, otherwise the assignment // below will crash randomly scancode &= 0xff; keys[(int)key] = scancodes[scancode] = state; if (state && KeyDown != null) { args.Key = key; args.ScanCode = scancode; args.Modifiers = mods; KeyDown(this, args); } else if (!state && KeyUp != null) { args.Key = key; args.ScanCode = scancode; args.Modifiers = mods; KeyUp(this, args); } } }
public KeyGesture(Key key, KeyModifiers modifiers = KeyModifiers.None) { Key = key; KeyModifiers = modifiers; }
static extern bool RegisterHotKey(IntPtr handle, int id, KeyModifiers modifiers, Keys vk);
public void Subscribe(KeyModifiers mod, Keys key, KeybindHandler handler) { Subscribe(mod, key, handler, null); }
public void SubscribeDefaults(KeyModifiers mod = KeyModifiers.LAlt) { Subscribe(MouseEvent.LButtonDown, () => _context.Workspaces.SwitchFocusedMonitorToMouseLocation()); Subscribe(mod | KeyModifiers.LShift, Keys.E, () => _context.Enabled = !_context.Enabled, "toggle enable/disable"); Subscribe(mod | KeyModifiers.LShift, Keys.C, () => _context.Workspaces.FocusedWorkspace.CloseFocusedWindow(), "close focused window"); Subscribe(mod, Keys.Space, () => _context.Workspaces.FocusedWorkspace.NextLayoutEngine(), "next layout"); Subscribe(mod | KeyModifiers.LShift, Keys.Space, () => _context.Workspaces.FocusedWorkspace.PreviousLayoutEngine(), "previous layout"); Subscribe(mod, Keys.N, () => _context.Workspaces.FocusedWorkspace.ResetLayout(), "reset layout"); Subscribe(mod, Keys.J, () => _context.Workspaces.FocusedWorkspace.FocusNextWindow(), "focus next window"); Subscribe(mod, Keys.K, () => _context.Workspaces.FocusedWorkspace.FocusPreviousWindow(), "focus previous window"); Subscribe(mod, Keys.M, () => _context.Workspaces.FocusedWorkspace.FocusPrimaryWindow(), "focus primary window"); Subscribe(mod, Keys.Enter, () => _context.Workspaces.FocusedWorkspace.SwapFocusAndPrimaryWindow(), "swap focus and primary window"); Subscribe(mod | KeyModifiers.LShift, Keys.J, () => _context.Workspaces.FocusedWorkspace.SwapFocusAndNextWindow(), "swap focus and next window"); Subscribe(mod | KeyModifiers.LShift, Keys.K, () => _context.Workspaces.FocusedWorkspace.SwapFocusAndPreviousWindow(), "swap focus and previous window"); Subscribe(mod, Keys.H, () => _context.Workspaces.FocusedWorkspace.ShrinkPrimaryArea(), "shrink primary area"); Subscribe(mod, Keys.L, () => _context.Workspaces.FocusedWorkspace.ExpandPrimaryArea(), "expand primary area"); Subscribe(mod, Keys.Oemcomma, () => _context.Workspaces.FocusedWorkspace.IncrementNumberOfPrimaryWindows(), "increment # primary windows"); Subscribe(mod, Keys.OemPeriod, () => _context.Workspaces.FocusedWorkspace.DecrementNumberOfPrimaryWindows(), "decrement # primary windows"); Subscribe(mod, Keys.T, () => _context.Windows.ToggleFocusedWindowTiling(), "toggle tiling for focused window"); Subscribe(mod | KeyModifiers.LShift, Keys.Q, _context.Quit, "quit workspacer"); Subscribe(mod, Keys.Q, _context.Restart, "restart workspacer"); Subscribe(mod, Keys.D1, () => _context.Workspaces.SwitchToWorkspace(0), "switch to workspace 1"); Subscribe(mod, Keys.D2, () => _context.Workspaces.SwitchToWorkspace(1), "switch to workspace 2"); Subscribe(mod, Keys.D3, () => _context.Workspaces.SwitchToWorkspace(2), "switch to workspace 3"); Subscribe(mod, Keys.D4, () => _context.Workspaces.SwitchToWorkspace(3), "switch to workspace 4"); Subscribe(mod, Keys.D5, () => _context.Workspaces.SwitchToWorkspace(4), "switch to workspace 5"); Subscribe(mod, Keys.D6, () => _context.Workspaces.SwitchToWorkspace(5), "switch to workspace 6"); Subscribe(mod, Keys.D7, () => _context.Workspaces.SwitchToWorkspace(6), "switch to workspace 7"); Subscribe(mod, Keys.D8, () => _context.Workspaces.SwitchToWorkspace(7), "switch to workspace 8"); Subscribe(mod, Keys.D9, () => _context.Workspaces.SwitchToWorkspace(8), "switch to workpsace 9"); Subscribe(mod, Keys.Left, () => _context.Workspaces.SwitchToPreviousWorkspace(), "switch to previous workspace"); Subscribe(mod, Keys.Right, () => _context.Workspaces.SwitchToNextWorkspace(), "switch to next workspace"); Subscribe(mod, Keys.Oemtilde, () => _context.Workspaces.SwitchToLastFocusedWorkspace(), "switch to last focused workspace"); Subscribe(mod, Keys.W, () => _context.Workspaces.SwitchFocusedMonitor(0), "focus monitor 1"); Subscribe(mod, Keys.E, () => _context.Workspaces.SwitchFocusedMonitor(1), "focus monitor 2"); Subscribe(mod, Keys.R, () => _context.Workspaces.SwitchFocusedMonitor(2), "focus monitor 3"); Subscribe(mod | KeyModifiers.LShift, Keys.W, () => _context.Workspaces.MoveFocusedWindowToMonitor(0), "move focused window to monitor 1"); Subscribe(mod | KeyModifiers.LShift, Keys.E, () => _context.Workspaces.MoveFocusedWindowToMonitor(1), "move focused window to monitor 2"); Subscribe(mod | KeyModifiers.LShift, Keys.R, () => _context.Workspaces.MoveFocusedWindowToMonitor(2), "move focused window to monitor 3"); Subscribe(mod | KeyModifiers.LShift, Keys.D1, () => _context.Workspaces.MoveFocusedWindowToWorkspace(0), "switch focused window to workspace 1"); Subscribe(mod | KeyModifiers.LShift, Keys.D2, () => _context.Workspaces.MoveFocusedWindowToWorkspace(1), "switch focused window to workspace 2"); Subscribe(mod | KeyModifiers.LShift, Keys.D3, () => _context.Workspaces.MoveFocusedWindowToWorkspace(2), "switch focused window to workspace 3"); Subscribe(mod | KeyModifiers.LShift, Keys.D4, () => _context.Workspaces.MoveFocusedWindowToWorkspace(3), "switch focused window to workspace 4"); Subscribe(mod | KeyModifiers.LShift, Keys.D5, () => _context.Workspaces.MoveFocusedWindowToWorkspace(4), "switch focused window to workspace 5"); Subscribe(mod | KeyModifiers.LShift, Keys.D6, () => _context.Workspaces.MoveFocusedWindowToWorkspace(5), "switch focused window to workspace 6"); Subscribe(mod | KeyModifiers.LShift, Keys.D7, () => _context.Workspaces.MoveFocusedWindowToWorkspace(6), "switch focused window to workspace 7"); Subscribe(mod | KeyModifiers.LShift, Keys.D8, () => _context.Workspaces.MoveFocusedWindowToWorkspace(7), "switch focused window to workspace 8"); Subscribe(mod | KeyModifiers.LShift, Keys.D9, () => _context.Workspaces.MoveFocusedWindowToWorkspace(8), "switch focused window to workspace 9"); Subscribe(mod, Keys.O, () => _context.Windows.DumpWindowDebugOutput(), "dump debug info to console for all windows"); Subscribe(mod | KeyModifiers.LShift, Keys.O, () => _context.Windows.DumpWindowUnderCursorDebugOutput(), "dump debug info to console for window under cursor"); Subscribe(mod | KeyModifiers.LShift, Keys.I, () => _context.ToggleConsoleWindow(), "toggle debug console"); Subscribe(mod | KeyModifiers.LShift, Keys.Oem2, () => ShowKeybindDialog(), "open keybind window"); }
public OnKeyEventEventHandler(Keys key, KeyModifiers modifiers) { Key = key; Modifiers = modifiers; }
public static extern bool RegisterHotKey( IntPtr hWnd, // handle to window int id, // hot key identifier KeyModifiers fsModifiers, // key-modifier options System.Windows.Forms.Keys vk // virtual-key code );
private static extern bool UnregisterFunc1(KeyModifiers modifiers, int keyID);
public HotKeyEventArgs(Keys key, KeyModifiers modifiers) { Key = key; Modifiers = modifiers; }
public static extern bool RegisterHotKey( IntPtr hWnd, // handle to window int id, // hot key identifier KeyModifiers Modifiers, // key-modifier options int key //virtual-key code );
public static extern bool RegisterHotKey(IntPtr hWnd, int id, KeyModifiers fsModifiers, System.Windows.Forms.Keys vk);
PointerEventArgs CreateSimpleEvent(RoutedEvent ev, ulong timestamp, IInteractive source, PointerPointProperties properties, KeyModifiers inputModifiers) { return(new PointerEventArgs(ev, source, _pointer, null, default,
public static extern bool RegisterHotKey(IntPtr hWnd, // handle to window int id, // hot key identifier KeyModifiers fsModifiers, // key-modifier options Keys vk // virtual-key code );
private void MouseDownEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers) { }
private static KeyInput ApplyModifiers(char c, KeyModifiers keyModifiers) { var keyInput = KeyInputUtil.CharToKeyInput(c); return KeyInputUtil.ApplyModifiers(keyInput, keyModifiers); }
private void EscapeKey(int eventCode, GameTime gameTime, KeyEventType eventType, KeyModifiers modifiers) { if (modalWindow != null && eventCode == escapeKeyCode) { CloseWindow(modalWindow); } }
/// <summary> /// Initializes a new instance of the <see cref="MouseButtonEventArgs" /> struct. /// </summary> /// <param name="button">The mouse button for the event.</param> /// <param name="action">The action of the mouse button.</param> /// <param name="modifiers">The key modifiers held during the mouse button's action.</param> public MouseButtonEventArgs(MouseButton button, InputAction action, KeyModifiers modifiers) { Button = button; Action = action; Modifiers = modifiers; }
private void c1186c0e88c5b95d1280f74b021cffe99(object c32c3d50ef5725e6c8f1a2ea14bb42003, EventArgs c2bba0636d27ec9b98b39d7d3d3d4f2c9) { try { System.Type type2; KeyModifiers none = KeyModifiers.None; if (!this.ca66a13ae5977351b2cccf2fca029a5be.Checked) { goto Label_0026; } Label_000F: switch (1) { case 0: goto Label_000F; default: if (1 == 0) { } none |= KeyModifiers.Alt; break; } Label_0026: if (!this.cb86db132c4f6d193dc502b3e39164243.Checked) { goto Label_0041; } Label_0033: switch (4) { case 0: goto Label_0033; default: none |= KeyModifiers.Control; break; } Label_0041: if (!this.c4f87bf351a1de5658a7197d58a786963.Checked) { goto Label_005E; } Label_0050: switch (5) { case 0: goto Label_0050; default: none |= KeyModifiers.Shift; break; } Label_005E: if (!this.c60d7235c8b764994456e271241c4de04.Checked) { goto Label_0079; } Label_006B: switch (3) { case 0: goto Label_006B; default: none |= KeyModifiers.Win; break; } Label_0079: type2 = typeof(Keys); string text = this.c1fa94719601dbe36472382cc2ca6a3e6.Text; object obj3 = Enum.Parse(type2, text); Keys keys = (Keys)obj3; this.c6902301418a3edf088649b116e8e631d.cbb54993ced46008451a87fbe1842ccbd(keys, none); this.c6902301418a3edf088649b116e8e631d.c3dec5d5039b98eb2d4080a89603d3266(); } catch { } base.Close(); }
public void Subscribe(KeyModifiers mod, Keys key, KeybindHandler handler, string name) { var sub = new Sub(mod, key); _kbdSubs[sub] = new NamedBind <KeybindHandler>(handler, name); }
public void SendKeys_Test() { Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true))); var top = Application.Top; var view = new View(); var shift = false; var alt = false; var control = false; Key key = default; Key lastKey = default; List <Key> keyEnums = GetKeys(); int i = 0; int idxKey = 0; var PushIterations = 0; var PopIterations = 0; List <Key> GetKeys() { List <Key> keys = new List <Key> (); foreach (Key k in Enum.GetValues(typeof(Key))) { if ((uint)k <= 0xff) { keys.Add(k); } else if ((uint)k > 0xff) { break; } } return(keys); } view.KeyPress += (e) => { e.Handled = true; PopIterations++; var rMk = new KeyModifiers() { Shift = e.KeyEvent.IsShift, Alt = e.KeyEvent.IsAlt, Ctrl = e.KeyEvent.IsCtrl }; lastKey = ShortcutHelper.GetModifiersKey(new KeyEvent(e.KeyEvent.Key, rMk)); Assert.Equal(key, lastKey); }; top.Add(view); Application.Iteration += () => { switch (i) { case 0: SendKeys(); break; case 1: shift = true; SendKeys(); break; case 2: alt = true; SendKeys(); break; case 3: control = true; SendKeys(); break; } if (PushIterations == keyEnums.Count * 4) { Application.RequestStop(); } }; void SendKeys() { var k = keyEnums [idxKey]; var c = (char)k; var ck = char.IsLetter(c) ? (ConsoleKey)char.ToUpper(c) : (ConsoleKey)c; var mk = new KeyModifiers() { Shift = shift, Alt = alt, Ctrl = control }; key = ShortcutHelper.GetModifiersKey(new KeyEvent(k, mk)); Application.Driver.SendKeys(c, ck, shift, alt, control); PushIterations++; if (idxKey + 1 < keyEnums.Count) { idxKey++; } else { idxKey = 0; i++; } } Application.Run(); Assert.Equal(key, lastKey); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown(); }
static void ProcessGlobalHotkeyLine(string line) { string key = line.Substring(0, line.IndexOf(" ")); string command = line.Substring(line.IndexOf(" ") + 1); string[] parts = key.Split('+'); KeyModifiers mod = KeyModifiers.None; int vk; for (int i = 0; i < parts.Length - 1; i++) { string umod = parts[i].ToUpper(); if (umod == "ALT") { mod |= KeyModifiers.Alt; } if (umod == "CTRL") { mod |= KeyModifiers.Ctrl; } if (umod == "SHIFT") { mod |= KeyModifiers.Shift; } if (umod == "WIN") { mod |= KeyModifiers.Win; } } key = parts[parts.Length - 1]; if (key.Length == 1) { short result = VkKeyScanEx(key[0], GetKeyboardLayout(0)); int hi = result >> 8; int lo = result & 0xFF; vk = lo; if ((hi & 1) == 1) { mod |= KeyModifiers.Shift; } if ((hi & 2) == 2) { mod |= KeyModifiers.Ctrl; } if ((hi & 4) == 4) { mod |= KeyModifiers.Alt; } } else { vk = mpv_to_VK(key); } if (Commands == null) { Commands = new Dictionary <int, string>(); } if (vk > 0) { Commands[ID] = command.Trim(); bool success = RegisterHotKey(HWND, ID++, mod, vk); if (!success) { Terminal.WriteError(line + ": " + new Win32Exception().Message + "\n", "global-input.conf"); } } }
private static void OnKey(GlfwWindowPtr wnd, Key key, int scanCode, KeyAction action, KeyModifiers mods) { if (action == KeyAction.Press) { keys[(int)key] = true; } else if (action == KeyAction.Release) { keys[(int)key] = false; } }
public BeltClickEvent(int slot, MouseButton button, KeyModifiers mods) { Slot = slot; Button = button; Modifiers = mods; }
public static extern bool RegisterHotKey( IntPtr hWnd, //要定义热键的窗口的句柄 int id, //定义热键ID(不能与其它ID重复) KeyModifiers fsModifiers, //标识热键是否在按Alt、Ctrl、Shift、Windows等键时才会生效 Keys vk //定义热键的内容 );
private static void AddBinding(RoutedCommand command, KeyModifiers modifiers, Key key, EventHandler <ExecutedRoutedEventArgs> handler) { AddBinding(command, new KeyGesture(key, modifiers), handler); }
private static void SimulateKey(IKeyboard keyboard, KeyCode key, string keyChar, KeyModifiers modifiers = null) { modifiers = modifiers ?? new KeyModifiers(); KeyPressedEventArgs keyDownEventArgs = new KeyPressedEventArgs { KeyChar = keyChar, VirtualKey = key, Modifiers = modifiers }; KeyTypedEventArgs keyPressEventArgs = new KeyTypedEventArgs { KeyChar = keyChar, VirtualKey = key, Modifiers = modifiers }; KeyReleasedEventArgs keyUpEventArgs = new KeyReleasedEventArgs { VirtualKey = key, Modifiers = modifiers }; keyboard.KeyPressed.Raise(keyDownEventArgs); keyboard.KeyTyped.Raise(keyPressEventArgs); keyboard.KeyReleased.Raise(keyUpEventArgs); }
public HotKeyRegister(IntPtr handle, int id, KeyModifiers modifiers, Keys key) { if (key == Keys.None || modifiers == KeyModifiers.None) { throw new ArgumentException("The key or modifiers could not be None."); } this.Handle = handle; this.ID = id; this.Modifiers = modifiers; this.Key = key; RegisterHotKey(); // Adds a message filter to monitor Windows messages as they are routed to // their destinations. Application.AddMessageFilter(this); }
internal void OnMouseLeftButtonUp_Click(KeyModifiers keyModifiers, ref bool handled) { // completed a click without dragging, so we're sorting InvokeProcessSort(keyModifiers); handled = true; }
private void OnKeyCallback(GlfwWindowPtr wnd, Key key, int scanCode, KeyAction action, KeyModifiers mods) { if (key == Key.LeftAlt | key == Key.RightAlt && key == Key.F4 & action == KeyAction.Press) Glfw.Terminate(); }
//TODO GroupSorting internal void ProcessSort(KeyModifiers keyModifiers, ListSortDirection?forcedDirection = null) { // if we can sort: // - AllowUserToSortColumns and CanSort are true, and // - OwningColumn is bound // then try to sort if (OwningColumn != null && OwningGrid != null && OwningGrid.EditingRow == null && OwningColumn != OwningGrid.ColumnsInternal.FillerColumn && OwningGrid.CanUserSortColumns && OwningColumn.CanUserSort) { var ea = new DataGridColumnEventArgs(OwningColumn); OwningGrid.OnColumnSorting(ea); if (!ea.Handled && OwningGrid.DataConnection.AllowSort && OwningGrid.DataConnection.SortDescriptions != null) { // - DataConnection.AllowSort is true, and // - SortDescriptionsCollection exists, and // - the column's data type is comparable DataGrid owningGrid = OwningGrid; DataGridSortDescription newSort; KeyboardHelper.GetMetaKeyState(keyModifiers, out bool ctrl, out bool shift); DataGridSortDescription sort = OwningColumn.GetSortDescription(); IDataGridCollectionView collectionView = owningGrid.DataConnection.CollectionView; Debug.Assert(collectionView != null); using (collectionView.DeferRefresh()) { // if shift is held down, we multi-sort, therefore if it isn't, we'll clear the sorts beforehand if (!shift || owningGrid.DataConnection.SortDescriptions.Count == 0) { owningGrid.DataConnection.SortDescriptions.Clear(); } // if ctrl is held down, we only clear the sort directions if (!ctrl) { if (sort != null) { if (forcedDirection == null || sort.Direction != forcedDirection) { newSort = sort.SwitchSortDirection(); } else { newSort = sort; } // changing direction should not affect sort order, so we replace this column's // sort description instead of just adding it to the end of the collection int oldIndex = owningGrid.DataConnection.SortDescriptions.IndexOf(sort); if (oldIndex >= 0) { owningGrid.DataConnection.SortDescriptions.Remove(sort); owningGrid.DataConnection.SortDescriptions.Insert(oldIndex, newSort); } else { owningGrid.DataConnection.SortDescriptions.Add(newSort); } } else if (OwningColumn.CustomSortComparer != null) { newSort = forcedDirection != null? DataGridSortDescription.FromComparer(OwningColumn.CustomSortComparer, forcedDirection.Value) : DataGridSortDescription.FromComparer(OwningColumn.CustomSortComparer); owningGrid.DataConnection.SortDescriptions.Add(newSort); } else { string propertyName = OwningColumn.GetSortPropertyName(); // no-opt if we couldn't find a property to sort on if (string.IsNullOrEmpty(propertyName)) { return; } newSort = DataGridSortDescription.FromPath(propertyName, culture: collectionView.Culture); if (forcedDirection != null && newSort.Direction != forcedDirection) { newSort = newSort.SwitchSortDirection(); } owningGrid.DataConnection.SortDescriptions.Add(newSort); } } } } } }
private static CommandKeyBinding CreateCommandKeyBinding(KeyInput input, KeyModifiers modifiers = KeyModifiers.None, string name = "again", string scope = "Global") { var stroke = new KeyStroke(input, modifiers); var key = new VsVim.KeyBinding(scope, stroke); return new CommandKeyBinding(name, key); }
public InternalKeyMappingEntry(int keyCode, KeyModifiers modifiers, string value) { KeyCode = keyCode; Modifiers = modifiers; Value = value ?? throw new ArgumentNullException(nameof(value)); }
public static extern bool RegisterHotKey(IntPtr hWnd, int id, KeyModifiers fsModifiers, Keys vk);
public ScrollEventArgs(int delta, KeyModifiers keyModifiers) { Delta = delta; Modifiers = keyModifiers; }
internal KeyPressedEventArgs(int id, KeyModifiers modifier, Keys key) { this.id = id; this.modifier = modifier; this.key = key; }
public HotKeyEventArgs(Keys key, KeyModifiers modifiers) { this.Key = key; this.Modifiers = modifiers; }
public Hotkey(Keys key, KeyModifiers modifiers) { Key = key; Modifier = modifiers; }