mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixed a bunch of Keybinding issues
This commit is contained in:
@@ -8,13 +8,14 @@ public class BarItem : View {
|
||||
public BarItem ()
|
||||
{
|
||||
Height = 1;
|
||||
AddCommand (Command.ToggleExpandCollapse, () => { Visible = !Visible; return true; });
|
||||
}
|
||||
public override string Text {
|
||||
set {
|
||||
base.Text = $"{KeyBindings.Bindings.FirstOrDefault (b => b.Value.Scope != KeyBindingScope.Focused).Key} `{value}`";
|
||||
base.Text = $"{KeyBindings.Bindings.FirstOrDefault (b => b.Value.Scope != KeyBindingScope.Focused).Key} {value}";
|
||||
}
|
||||
get {
|
||||
return $"{KeyBindings.Bindings.FirstOrDefault(b => b.Value.Scope != KeyBindingScope.Focused).Key} `{base.Text}`";
|
||||
return $"{KeyBindings.Bindings.FirstOrDefault(b => b.Value.Scope != KeyBindingScope.Focused).Key} {base.Text}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +37,7 @@ public class Bar : View {
|
||||
Height = 1;
|
||||
AutoSize = false;
|
||||
ColorScheme = Colors.Menu;
|
||||
CanFocus = true;
|
||||
}
|
||||
|
||||
public override void Add (View view)
|
||||
|
||||
52
UICatalog/Scenarios/Bars.cs
Normal file
52
UICatalog/Scenarios/Bars.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Terminal.Gui;
|
||||
|
||||
namespace UICatalog.Scenarios;
|
||||
[ScenarioMetadata (Name: "Bars", Description: "Illustrates Bar views (e.g. StatusBar)")]
|
||||
[ScenarioCategory ("Controls")]
|
||||
public class bars : Scenario {
|
||||
public override void Init ()
|
||||
{
|
||||
Application.Init ();
|
||||
ConfigurationManager.Themes.Theme = Theme;
|
||||
ConfigurationManager.Apply ();
|
||||
Application.Top.ColorScheme = Colors.ColorSchemes [TopLevelColorScheme];
|
||||
Application.Top.Loaded += Top_Initialized;
|
||||
}
|
||||
|
||||
// Setting everything up in Initialized handler because we change the
|
||||
// QuitKey and it only sticks if changed after init
|
||||
void Top_Initialized (object sender, System.EventArgs e)
|
||||
{
|
||||
Application.QuitKey = Key.Z.WithCtrl;
|
||||
|
||||
var bar = new Bar () {
|
||||
};
|
||||
var barITem = new BarItem () { Text = $"Quit - {Application.QuitKey}", AutoSize = true };
|
||||
barITem.KeyBindings.Add (Application.QuitKey, KeyBindingScope.Application, Command.QuitToplevel);
|
||||
bar.Add (barITem);
|
||||
|
||||
barITem = new BarItem () { Text = $"Show/Hide - {Key.F10}", AutoSize = true };
|
||||
barITem.KeyBindings.Add (Key.F10, KeyBindingScope.Application, Command.ToggleExpandCollapse);
|
||||
bar.Add (barITem);
|
||||
|
||||
bar.Add (new Label () { Text = "FocusLabel", CanFocus = true });
|
||||
|
||||
var button = new Button ("Press me!") {
|
||||
AutoSize = true
|
||||
};
|
||||
button.Clicked += Button_Clicked;
|
||||
|
||||
bar.Add (button);
|
||||
|
||||
button = new Button ("Or me!") {
|
||||
AutoSize = true,
|
||||
};
|
||||
button.Clicked += Button_Clicked;
|
||||
|
||||
bar.Add (button);
|
||||
|
||||
Application.Top.Add (bar);
|
||||
}
|
||||
|
||||
void Button_Clicked (object sender, System.EventArgs e) => MessageBox.Query("Hi", $"You clicked {sender}");
|
||||
}
|
||||
Reference in New Issue
Block a user