forked from OpenRakis/Spice86
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
- Loading branch information
1 parent
b32b4cc
commit 7a10961
Showing
3 changed files
with
59 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Spice86.Controls; | ||
|
||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
|
||
using System.Windows.Input; | ||
|
||
/// <summary> | ||
/// A TabItem with a hot key. | ||
/// <remarks>Source is: https://github.com/AvaloniaUI/Avalonia/discussions/14836</remarks> | ||
/// </summary> | ||
public class HotKeyTabItem : TabItem, ICommandSource { | ||
protected override Type StyleKeyOverride => typeof(TabItem); | ||
|
||
public HotKeyTabItem() { | ||
Command = new TabItemSelectCommand(this); | ||
CommandParameter = null; | ||
} | ||
|
||
public void CanExecuteChanged(object sender, EventArgs e) { | ||
} | ||
|
||
public ICommand? Command { get; } | ||
public object? CommandParameter { get; } | ||
|
||
public class TabItemSelectCommand : ICommand { | ||
private readonly TabItem _tabItem; | ||
|
||
public TabItemSelectCommand(TabItem tabItem) { | ||
_tabItem = tabItem; | ||
} | ||
|
||
public bool CanExecute(object? parameter) { | ||
return _tabItem.IsEffectivelyEnabled; | ||
} | ||
|
||
public void Execute(object? parameter) { | ||
_tabItem.IsSelected = true; | ||
} | ||
|
||
public event EventHandler? CanExecuteChanged; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters