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

Commit 2f48e74

Browse files
authored
Merge pull request #9168 from mono/backport-pr-9150-to-release-8.4
[release-8.4] Keyboard focus not going to "Pause Execution" button
2 parents 8b7ee7a + 78379a6 commit 2f48e74

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

main/src/addins/MacPlatform/MainToolbar/AwesomeBar.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public AwesomeBar ()
6464

6565
StatusBar.SearchBar = SearchBar;
6666

67+
RunButton.NextKeyView = SelectorView;
68+
SelectorView.NextKeyView = ButtonBarContainer;
69+
ButtonBarContainer.NextKeyView = StatusBar;
70+
StatusBar.NextKeyView = SearchBar;
71+
6772
Ide.Gui.Styles.Changed += (o, e) => UpdateLayout ();
6873
}
6974

main/src/addins/MacPlatform/MainToolbar/ButtonBar.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ public bool HasFocus {
240240
RebuildSegments ();
241241
}
242242
}
243+
243244
uint focusedSegment = 0;
244245
public bool IncreaseFocusIndex()
245246
{
@@ -254,6 +255,16 @@ public bool IncreaseFocusIndex()
254255
};
255256
return result;
256257
}
258+
259+
public bool DecreaseFocusIndex ()
260+
{
261+
if (focusedSegment == 0)
262+
return false;
263+
focusedSegment--;
264+
RebuildSegments ();
265+
return true;
266+
}
267+
257268
public event EventHandler ResizeRequested;
258269
}
259270
}

main/src/addins/MacPlatform/MainToolbar/ButtonBarContainer.cs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
// THE SOFTWARE.
2626
using System;
2727
using System.Collections.Generic;
28+
using System.Linq;
2829
using AppKit;
2930
using CoreGraphics;
3031
using MonoDevelop.Ide;
31-
using System.Linq;
32+
using MonoDevelop.Components.Mac;
3233

3334
namespace MonoDevelop.MacIntegration.MainToolbar
3435
{
@@ -61,21 +62,30 @@ internal List<ButtonBar> ButtonBars {
6162
}
6263

6364
public override void KeyDown (NSEvent theEvent)
64-
{
65-
if (theEvent.Characters == "\t" && NextKeyView != null) {
66-
var success = buttonBars.FirstOrDefault ().IncreaseFocusIndex(); //TODO
67-
if(!success)
68-
Window.MakeFirstResponder (NextKeyView);
69-
return;
70-
}
71-
72-
if (theEvent.Characters == " " && NextKeyView != null) {
73-
var buttonBar = buttonBars.FirstOrDefault ();
74-
buttonBar.ExecuteFocused ();
65+
{
66+
if (theEvent.KeyCode == (ushort)KeyCodes.Tab) {
67+
if (theEvent.ModifierFlags == (NSEventModifierMask)KeyModifierFlag.None) {
68+
if (buttonBars.Count > 0) {
69+
var success = buttonBars[0].IncreaseFocusIndex ();
70+
if (success) return;
71+
}
72+
} else if (theEvent.ModifierFlags == (NSEventModifierMask)KeyModifierFlag.Shift) {
73+
if (buttonBars.Count > 0) {
74+
var success = buttonBars[0].DecreaseFocusIndex ();
75+
if (success) return;
76+
}
77+
}
78+
} else if (theEvent.KeyCode == (ushort)KeyCodes.Space || theEvent.KeyCode == (ushort)KeyCodes.Enter) {
79+
if (buttonBars.Count > 0) {
80+
var buttonBar = buttonBars[0];
81+
buttonBar.ExecuteFocused ();
82+
}
7583
}
7684

77-
base.KeyDown (theEvent);
78-
}
85+
base.KeyDown (theEvent);
86+
}
87+
88+
public override bool AcceptsFirstResponder () => buttonBars.Any ();
7989

8090
public override bool BecomeFirstResponder ()
8191
{

main/src/addins/MacPlatform/MainToolbar/MainToolbar.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ public void RebuildToolbar (IEnumerable<ButtonBarGroup> groups)
236236
};
237237
buttonBars.Add (bar);
238238
}
239-
240239
awesomeBar.ButtonBarContainer.ButtonBars = buttonBars;
241240
}
242241

0 commit comments

Comments
 (0)