2
0
Эх сурвалжийг харах

ComboBox hand pick @BDisp changes:-
Test dir more robust "\Windows"
Use ListViewItemEventArgs

Ross Ferguson 5 жил өмнө
parent
commit
de5a30bb90

+ 2 - 2
Example/demo.cs

@@ -451,7 +451,7 @@ static class Demo {
 	static void ComboBoxDemo ()
 	{
 		List<ustring> items = new List<ustring> ();
-		foreach (var dir in new [] { "/etc", @"\windows\System32" }) {
+		foreach (var dir in new [] { "/etc", @$"{Environment.GetEnvironmentVariable ("SystemRoot")}\System32" }) {
 			if (Directory.Exists (dir)) {
 				items = Directory.GetFiles (dir).Union (Directory.GetDirectories (dir))
 					.Select (Path.GetFileName)
@@ -461,7 +461,7 @@ static class Demo {
 		}
 		var list = new ComboBox () { Width = Dim.Fill(), Height = Dim.Fill() };
 		list.SetSource(items.ToList());
-		list.SelectedItemChanged += (object sender, ustring text) => { Application.RequestStop (); };
+		list.SelectedItemChanged += (object sender, ListViewItemEventArgs text) => { Application.RequestStop (); };
 
 		var d = new Dialog () { Title = "Select source file", Width = Dim.Percent (50), Height = Dim.Percent (50) };
 		d.Add (list);

+ 2 - 2
Terminal.Gui/Views/ComboBox.cs

@@ -61,7 +61,7 @@ namespace Terminal.Gui {
 		///   Client code can hook up to this event, it is
 		///   raised when the selection has been confirmed.
 		/// </remarks>
-		public event EventHandler<ustring> SelectedItemChanged;
+		public event EventHandler<ListViewItemEventArgs> SelectedItemChanged;
 
 		IList searchset;
 		ustring text = "";
@@ -209,7 +209,7 @@ namespace Terminal.Gui {
 		{
 			// Note: Cannot rely on "listview.SelectedItem != lastSelectedItem" because the list is dynamic. 
 			// So we cannot optimize. Ie: Don't call if not changed
-			SelectedItemChanged?.Invoke (this, search.Text);
+			SelectedItemChanged?.Invoke (this, new ListViewItemEventArgs(listview.SelectedItem, search.Text));
 
 			return true;
 		}

+ 2 - 2
UICatalog/Scenarios/ListsAndCombos.cs

@@ -13,7 +13,7 @@ namespace UICatalog.Scenarios {
 		public override void Setup ()
 		{
 			List<ustring> items = new List<ustring> ();
-			foreach (var dir in new [] { "/etc", @"\windows\System32" }) {
+			foreach (var dir in new [] { "/etc", @$"{Environment.GetEnvironmentVariable ("SystemRoot")}\System32" }) {
 				if (Directory.Exists (dir)) {
 					items = Directory.GetFiles (dir).Union(Directory.GetDirectories(dir))
 						.Select (Path.GetFileName)
@@ -53,7 +53,7 @@ namespace UICatalog.Scenarios {
 			};
 			comboBox.SetSource (items);
 
-			comboBox.SelectedItemChanged += (object sender, ustring text) => lbComboBox.Text = text;
+			comboBox.SelectedItemChanged += (object sender, ListViewItemEventArgs text) => lbComboBox.Text = (ustring)text.Value;
 			Win.Add (lbComboBox, comboBox);
 		}
 	}