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

Commit b1e9d0d

Browse files
GouriKumarimonojenkins
authored andcommitted
Set the proper NextResponder chain in awesomebar.cs and fix custom foxus handling in buttonbar.cs
1 parent f824cee commit b1e9d0d

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
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: 19 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,25 @@ 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+
var success = buttonBars.FirstOrDefault ().IncreaseFocusIndex ();
69+
if (success) return;
70+
} else if (theEvent.ModifierFlags == (NSEventModifierMask)KeyModifierFlag.Shift) {
71+
var success = buttonBars.FirstOrDefault ().DecreaseFocusIndex ();
72+
if (success) return;
73+
}
74+
} else if (theEvent.KeyCode == (ushort)KeyCodes.Space || theEvent.KeyCode == (ushort)KeyCodes.Enter) {
75+
var buttonBar = buttonBars.FirstOrDefault ();
76+
buttonBar.ExecuteFocused ();
7577
}
7678

77-
base.KeyDown (theEvent);
78-
}
79+
base.KeyDown (theEvent);
80+
}
81+
82+
83+
public override bool AcceptsFirstResponder () => buttonBars.Any ();
7984

8085
public override bool BecomeFirstResponder ()
8186
{

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,6 @@ public void RebuildToolbar (IEnumerable<ButtonBarGroup> groups)
239239

240240
awesomeBar.ButtonBarContainer.ButtonBars = buttonBars;
241241

242-
foreach (var button in awesomeBar.ButtonBarContainer.ButtonBars) {
243-
if (button.Enabled)
244-
runButton.NextKeyView = button;
245-
}
246242
}
247243

248244
public bool RunButtonSensitivity {

0 commit comments

Comments
 (0)