mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 09:18:01 +01:00
* Added View.DefaultCommand etc... Started on dedicated scenario * Fixed un-shifted hotkeys -> Fixed Key Equals. Fixed WindowsDriver passing wrong key. Etc. * Fixed Key Bindings and HotKeys * Fixed Key Bindings and HotKeys * Label now correctly supports hotkey * Disabled unix hot keys because they are annoying and get in the way * Updated nuget. fixed warnings * Trying to fix ci/ci issue * Trying to fix ci/ci issue * Trying to fix ci/ci issue * Changed TextChangingEventArgs to inherit from CancelEventArgs * TextChangingEventArgs -> TextEventArgs * Simplified Text events by having only on args class * Fixed unit tests fail * Simplified by removing TitleEventArgs * POC of Title being primary for hotkey. Label and Button hacked to work * POC of Title being primary for hotkey. Label and Button hacked to work - all unit tests pass * Dropped Microsoft.NETFramework.ReferenceAssemblies * Fixed Dialogs scenario hotkeys * Fixed build warnings * Fixed Border Title render bug * Regiggering default command handling * Regiggering default command handling * Checkbox clean up * Added StateEventArgs POC * Command.Default -> Command.HotKey * Command.Default -> Command.HotKey - fixed TableView * Command.Default -> Command.HotKey - fixed TableView * Updated reactive example * Fixed Toplevel.BringOverlappedTopToFront - was reordering SubViews when it shouldn't * WIP - broke * Finished impl of StateEventArgs * Deleted ToggleEventArgs.cs. Added StateEventArgs.cs * XML doc fix * Removed old code * Removed commented out code * Label.Clicked -> Label.Accept (missed this before) * Removed Labels as Buttons scenario as it's not really useful * Moved SubView tests to own file * Moved SubView tests to own file * Simplified Text test * Added OnAccept test * Deleted DefaultCommand * Modernized CheckBox * New button test * Cleaned up RadioGroup; added tests * KeyCode->Key in ListView * Added ListView unit tests * ListView now does Accept correctly * TreeView now does Accept correctly * Cleaned up some TextField tests * TextView now handles Accept properly; updated CharMap and Adornments scenarios to test * Fixed ComboBox to deal with TextView now handles Accept properly; updated CharMap and Adornments scenarios to test * Removed un-needed using statement
82 lines
3.0 KiB
C#
82 lines
3.0 KiB
C#
using System.Collections.Generic;
|
|
using Terminal.Gui;
|
|
|
|
namespace UICatalog.Scenarios;
|
|
|
|
[ScenarioMetadata ("ComboBoxIteration", "ComboBox iteration.")]
|
|
[ScenarioCategory ("Controls")]
|
|
[ScenarioCategory ("ComboBox")]
|
|
public class ComboBoxIteration : Scenario
|
|
{
|
|
public override void Setup ()
|
|
{
|
|
List<string> items = new () { "one", "two", "three" };
|
|
|
|
var lbListView = new Label { AutoSize = false, Width = 10, Height = 1 };
|
|
Win.Add (lbListView);
|
|
|
|
var listview = new ListView
|
|
{
|
|
Y = Pos.Bottom (lbListView) + 1, Width = 10, Height = Dim.Fill (2), Source = new ListWrapper (items)
|
|
};
|
|
Win.Add (listview);
|
|
|
|
var lbComboBox = new Label
|
|
{
|
|
ColorScheme = Colors.ColorSchemes ["TopLevel"],
|
|
X = Pos.Right (lbListView) + 1,
|
|
AutoSize = false,
|
|
Width = Dim.Percent (40)
|
|
};
|
|
|
|
var comboBox = new ComboBox
|
|
{
|
|
X = Pos.Right (listview) + 1,
|
|
Y = Pos.Bottom (lbListView) + 1,
|
|
Height = Dim.Fill (2),
|
|
Width = Dim.Percent (40),
|
|
HideDropdownListOnClick = true
|
|
};
|
|
comboBox.SetSource (items);
|
|
|
|
listview.SelectedItemChanged += (s, e) =>
|
|
{
|
|
lbListView.Text = items [e.Item];
|
|
comboBox.SelectedItem = e.Item;
|
|
};
|
|
|
|
comboBox.SelectedItemChanged += (sender, text) =>
|
|
{
|
|
if (text.Item != -1)
|
|
{
|
|
lbComboBox.Text = text.Value.ToString ();
|
|
listview.SelectedItem = text.Item;
|
|
}
|
|
};
|
|
Win.Add (lbComboBox, comboBox);
|
|
Win.Add (new TextField { X = Pos.Right (listview) + 1, Y = Pos.Top (comboBox) + 3, Height = 1, Width = 20 });
|
|
|
|
var btnTwo = new Button { X = Pos.Right (comboBox) + 1, Text = "Two" };
|
|
|
|
btnTwo.Accept += (s, e) =>
|
|
{
|
|
items = new List<string> { "one", "two" };
|
|
comboBox.SetSource (items);
|
|
listview.SetSource (items);
|
|
listview.SelectedItem = 0;
|
|
};
|
|
Win.Add (btnTwo);
|
|
|
|
var btnThree = new Button { X = Pos.Right (comboBox) + 1, Y = Pos.Top (comboBox), Text = "Three" };
|
|
|
|
btnThree.Accept += (s, e) =>
|
|
{
|
|
items = new List<string> { "one", "two", "three" };
|
|
comboBox.SetSource (items);
|
|
listview.SetSource (items);
|
|
listview.SelectedItem = 0;
|
|
};
|
|
Win.Add (btnThree);
|
|
}
|
|
}
|