diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2019-10-07 11:42:28 +0300 |
---|---|---|
committer | monojenkins <jo.shields+jenkins@xamarin.com> | 2019-11-14 01:40:10 +0300 |
commit | 5636fd208b9dfe1b1c5051c6d12479aab0931062 (patch) | |
tree | 96469efe5174b5523af6bf2d49d9c0fa8e417a30 /main | |
parent | cb872ea9d3e11063a3e860dfb72db71b042d3cd3 (diff) |
[Ide] Allow to unfocus the Keybinding entry with keyboard
When/after recording a new key binding, there is now way
to finish the assignment for keyboard only users, because
a tab key combination will be always recorded and not executed.
This changes the behaviour and allows Gtk to handle the
focus event:
* Don't accept tab as chord and let Gtk move the focus
* For accels allow tab to be entered,
but don't reset on a second tab and let Gtk handle it again
* If the accel is complete, move focus without resetting the entry,
allowing the user to finish entering a binding
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs index 020b963c57..4a8ea03109 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs @@ -380,6 +380,21 @@ namespace MonoDevelop.Ide.Gui.OptionPanels CurrentSelectedBinding = null; } } + + void ResetAccelEntry () + { + CurrentKey = string.Empty; + accelIncomplete = false; + accelComplete = false; + chord = null; + } + + static bool GetIsFocusSwitchKey (Gdk.EventKey e) + { + // TAB to focus next or SHIFT+TAB to focus previous + return (e.Key == Gdk.Key.Tab || e.Key == Gdk.Key.ISO_Left_Tab) + && (e.State == Gdk.ModifierType.None || e.State == Gdk.ModifierType.ShiftMask); + } [GLib.ConnectBefore] void OnAccelEntryKeyPress (object sender, KeyPressEventArgs e) @@ -390,14 +405,24 @@ namespace MonoDevelop.Ide.Gui.OptionPanels e.RetVal = true; if (accelComplete) { - CurrentKey = String.Empty; - accelIncomplete = false; - accelComplete = false; - chord = null; - + // allow Gtk to handle the TAB combo (a11y: keyboard only users need to be able to move the focus) + if (GetIsFocusSwitchKey (e.Event)) { + e.RetVal = false; + return; + } + ResetAccelEntry (); if (key == Gdk.Key.BackSpace) return; } + // TAB / SHIFT-TAB are reserved and can not be used as chords + if (chord == null) { + if (GetIsFocusSwitchKey (e.Event)) { + ResetAccelEntry (); + // allow Gtk to handle the TAB combo (a11y: keyboard only users need to be able to move the focus) + e.RetVal = false; + return; + } + } accelComplete = false; bool combinationComplete; |