Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 957c6b3

Browse files
authored
Merge pull request #9274 from mono/backport-pr-9272-to-release-8.4
[release-8.4] [Ide] Allow to unfocus the Keybinding entry with keyboard
2 parents 220fd73 + 5636fd2 commit 957c6b3

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,21 @@ void OnKeysTreeViewSelectionChange (object sender, EventArgs e)
380380
CurrentSelectedBinding = null;
381381
}
382382
}
383+
384+
void ResetAccelEntry ()
385+
{
386+
CurrentKey = string.Empty;
387+
accelIncomplete = false;
388+
accelComplete = false;
389+
chord = null;
390+
}
391+
392+
static bool GetIsFocusSwitchKey (Gdk.EventKey e)
393+
{
394+
// TAB to focus next or SHIFT+TAB to focus previous
395+
return (e.Key == Gdk.Key.Tab || e.Key == Gdk.Key.ISO_Left_Tab)
396+
&& (e.State == Gdk.ModifierType.None || e.State == Gdk.ModifierType.ShiftMask);
397+
}
383398

384399
[GLib.ConnectBefore]
385400
void OnAccelEntryKeyPress (object sender, KeyPressEventArgs e)
@@ -390,14 +405,24 @@ void OnAccelEntryKeyPress (object sender, KeyPressEventArgs e)
390405
e.RetVal = true;
391406

392407
if (accelComplete) {
393-
CurrentKey = String.Empty;
394-
accelIncomplete = false;
395-
accelComplete = false;
396-
chord = null;
397-
408+
// allow Gtk to handle the TAB combo (a11y: keyboard only users need to be able to move the focus)
409+
if (GetIsFocusSwitchKey (e.Event)) {
410+
e.RetVal = false;
411+
return;
412+
}
413+
ResetAccelEntry ();
398414
if (key == Gdk.Key.BackSpace)
399415
return;
400416
}
417+
// TAB / SHIFT-TAB are reserved and can not be used as chords
418+
if (chord == null) {
419+
if (GetIsFocusSwitchKey (e.Event)) {
420+
ResetAccelEntry ();
421+
// allow Gtk to handle the TAB combo (a11y: keyboard only users need to be able to move the focus)
422+
e.RetVal = false;
423+
return;
424+
}
425+
}
401426

402427
accelComplete = false;
403428
bool combinationComplete;

0 commit comments

Comments
 (0)