protected override void OnKeyDown(KeyEventArgs kevent) { kevent.SuppressKeyPress = true; if (Editing) { if (kevent.KeyData == Keys.Escape) { Editing = false; Highlight = false; HotKey = PreHk; SetHkText(); OnHotKeyCanceled(this, EventArgs.Empty); return; } Key = kevent.KeyData; HotKey = new HotKeyData(Key); if (!HotKey.IsValidHotkey) { SetHkText(); return; } SetHkText(); OnHotKeyChanged(this, EventArgs.Empty); Editing = false; Highlight = false; } base.OnKeyDown(kevent); }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { //here we turn on/off editing mode. Editing = !Editing; Highlight = Editing; if (Editing) { PreHk = HotKey; OnHotKeyClicked(this, EventArgs.Empty); } else { OnHotKeyCanceled(this, EventArgs.Empty); } } else if (e.Button == MouseButtons.Right) { Editing = false; Highlight = false; Key = Keys.None; HotKey = new HotKeyData(Keys.None); SetHkText(); OnHotKeyChanged(this, EventArgs.Empty); } base.OnMouseUp(e); }
/// <inheritdoc /> public HotKeyDataBinder(HotKeyManager hotKeyManager, HotKeyData hotKeyData) { _hotKeyManager = hotKeyManager; HotKeyData = hotKeyData; HotKey = hotKeyData.ActualHotKey?.ToMahApps(); }
public void UnregisterHotKey(Keys key, HotKeyModifiers modifiers) { HotKeyData hkData = FindHotKey(key, modifiers); if (!hkData.Equals(HotKeyData.Empty)) { unregisterHotKey(hkData); hotkeys.Remove(hkData); } }
protected override void OnKeyUp(KeyEventArgs kevent) { kevent.SuppressKeyPress = true; if (Editing) { //only if printscreen because it's not triggered on keydown. if (kevent.KeyCode == Keys.PrintScreen) { Key = kevent.KeyData; HotKey = new HotKeyData(Key); if (!HotKey.IsValidHotkey) { SetHkText(); return; } SetHkText(); OnHotKeyChanged(this, EventArgs.Empty); Editing = false; Highlight = false; } } base.OnKeyUp(kevent); }
private void unregisterHotKey(HotKeyData hk) { UnregisterHotKey(this.Handle, hk.AtomID.ToInt32()); GlobalDeleteAtom(hk.AtomID); }
public bool AtomID_Equals(HotKeyData hk) { return this.AtomID == hk.AtomID; }