فهرست منبع

Merge pull request #774 from BDisp/unicode-scenario-combobox-fix

Fixes #773. Added a default drop down height to the ComboBox.
Charlie Kindel 5 سال پیش
والد
کامیت
1a5193082f
2فایلهای تغییر یافته به همراه8 افزوده شده و 5 حذف شده
  1. 6 1
      Terminal.Gui/Views/ComboBox.cs
  2. 2 4
      UICatalog/Scenarios/Unicode.cs

+ 6 - 1
Terminal.Gui/Views/ComboBox.cs

@@ -69,6 +69,7 @@ namespace Terminal.Gui {
 		readonly TextField search;
 		readonly ListView listview;
 		bool autoHide = true;
+		int minimumHeight = 2;
 
 		/// <summary>
 		/// Public constructor
@@ -110,6 +111,10 @@ namespace Terminal.Gui {
 
 		private void Initialize ()
 		{
+			if (Bounds.Height < minimumHeight && Height is Dim.DimAbsolute) {
+				Height = minimumHeight;
+			}
+
 			search.TextChanged += Search_Changed;
 
 			listview.Y = Pos.Bottom (search);
@@ -504,7 +509,7 @@ namespace Terminal.Gui {
 			if (Bounds.Height == 0)
 				return 0;
 
-			return Math.Min (Bounds.Height - 1, searchset?.Count > 0 ? searchset.Count : isShow ? Bounds.Height - 1 : 0);
+			return Math.Min (Math.Max(Bounds.Height - 1, minimumHeight - 1), searchset?.Count > 0 ? searchset.Count : isShow ? Math.Max (Bounds.Height - 1, minimumHeight - 1) : 0);
 		}
 	}
 }

+ 2 - 4
UICatalog/Scenarios/Unicode.cs

@@ -63,20 +63,18 @@ namespace UICatalog {
 			var checkBox = new CheckBox (gitString) { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
 			Win.Add (checkBox);
 
-			// BUGBUG: Combobox does not deal with unicode properly. 
-#if false
 			label = new Label ("ComboBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			Win.Add (label);
 			var comboBox = new ComboBox () {
 				X = 20,
 				Y = Pos.Y (label),
-				Width = Dim.Percent (50),
+				Width = Dim.Percent (50)
 			};
 			comboBox.SetSource (new List<string> () { gitString, "Со_хранить" });
 
 			Win.Add (comboBox);
 			comboBox.Text = gitString;
-#endif
+
 			label = new Label ("HexView:") { X = Pos.X (label), Y = Pos.Bottom (label) + 2 };
 			Win.Add (label);
 			var hexView = new HexView (new System.IO.MemoryStream (Encoding.ASCII.GetBytes (gitString + " Со_хранить"))) {