This repository was archived by the owner on Oct 4, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +35
-18
lines changed
main/src/addins/MacPlatform/MainToolbar Expand file tree Collapse file tree 4 files changed +35
-18
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 2525// THE SOFTWARE.
2626using System ;
2727using System . Collections . Generic ;
28+ using System . Linq ;
2829using AppKit ;
2930using CoreGraphics ;
3031using MonoDevelop . Ide ;
31- using System . Linq ;
32+ using MonoDevelop . Components . Mac ;
3233
3334namespace 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 {
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments