|
@@ -39,10 +39,7 @@ namespace Terminal.Gui {
|
|
|
|
|
|
private void Initialize (ComboBox container, bool hideDropdownListOnClick)
|
|
private void Initialize (ComboBox container, bool hideDropdownListOnClick)
|
|
{
|
|
{
|
|
- if (container == null)
|
|
|
|
- throw new ArgumentNullException ("ComboBox container cannot be null.", nameof (container));
|
|
|
|
-
|
|
|
|
- this.container = container;
|
|
|
|
|
|
+ this.container = container ?? throw new ArgumentNullException (nameof (container), "ComboBox container cannot be null.");
|
|
HideDropdownListOnClick = hideDropdownListOnClick;
|
|
HideDropdownListOnClick = hideDropdownListOnClick;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -236,7 +233,7 @@ namespace Terminal.Gui {
|
|
readonly TextField search;
|
|
readonly TextField search;
|
|
readonly ComboListView listview;
|
|
readonly ComboListView listview;
|
|
bool autoHide = true;
|
|
bool autoHide = true;
|
|
- int minimumHeight = 2;
|
|
|
|
|
|
+ readonly int minimumHeight = 2;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Public constructor
|
|
/// Public constructor
|
|
@@ -296,7 +293,7 @@ namespace Terminal.Gui {
|
|
listview.Y = Pos.Bottom (search);
|
|
listview.Y = Pos.Bottom (search);
|
|
listview.OpenSelectedItem += (object sender, ListViewItemEventArgs a) => Selected ();
|
|
listview.OpenSelectedItem += (object sender, ListViewItemEventArgs a) => Selected ();
|
|
|
|
|
|
- this.Add (search, listview);
|
|
|
|
|
|
+ Add (search, listview);
|
|
|
|
|
|
// On resize
|
|
// On resize
|
|
LayoutComplete += (object sender, LayoutEventArgs a) => {
|
|
LayoutComplete += (object sender, LayoutEventArgs a) => {
|
|
@@ -723,7 +720,19 @@ namespace Terminal.Gui {
|
|
return text;
|
|
return text;
|
|
}
|
|
}
|
|
set {
|
|
set {
|
|
- search.Text = text = value;
|
|
|
|
|
|
+ SetSearchText (value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Current search text
|
|
|
|
+ /// </summary>
|
|
|
|
+ public string SearchText {
|
|
|
|
+ get {
|
|
|
|
+ return search.Text;
|
|
|
|
+ }
|
|
|
|
+ set {
|
|
|
|
+ SetSearchText (value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -779,7 +788,7 @@ namespace Terminal.Gui {
|
|
private void Reset (bool keepSearchText = false)
|
|
private void Reset (bool keepSearchText = false)
|
|
{
|
|
{
|
|
if (!keepSearchText) {
|
|
if (!keepSearchText) {
|
|
- search.Text = text = "";
|
|
|
|
|
|
+ SetSearchText (string.Empty);
|
|
}
|
|
}
|
|
|
|
|
|
ResetSearchSet ();
|
|
ResetSearchSet ();
|
|
@@ -791,6 +800,10 @@ namespace Terminal.Gui {
|
|
search.SetFocus ();
|
|
search.SetFocus ();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ private void SetSearchText (string value)
|
|
|
|
+ {
|
|
|
|
+ search.Text = text = value;
|
|
|
|
+ }
|
|
|
|
|
|
private void ResetSearchSet (bool noCopy = false)
|
|
private void ResetSearchSet (bool noCopy = false)
|
|
{
|
|
{
|
|
@@ -847,7 +860,7 @@ namespace Terminal.Gui {
|
|
listview.SetSource (searchset);
|
|
listview.SetSource (searchset);
|
|
listview.Clear (); // Ensure list shrinks in Dialog as you type
|
|
listview.Clear (); // Ensure list shrinks in Dialog as you type
|
|
listview.Height = CalculatetHeight ();
|
|
listview.Height = CalculatetHeight ();
|
|
- this.SuperView?.BringSubviewToFront (this);
|
|
|
|
|
|
+ SuperView?.BringSubviewToFront (this);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -861,7 +874,8 @@ namespace Terminal.Gui {
|
|
OnOpenSelectedItem ();
|
|
OnOpenSelectedItem ();
|
|
}
|
|
}
|
|
var rect = listview.ViewToScreen (listview.Bounds);
|
|
var rect = listview.ViewToScreen (listview.Bounds);
|
|
- Reset (SelectedItem > -1);
|
|
|
|
|
|
+ Reset (keepSearchText: true);
|
|
|
|
+ listview.Clear (rect);
|
|
listview.Clear (rect);
|
|
listview.Clear (rect);
|
|
listview.TabStop = false;
|
|
listview.TabStop = false;
|
|
SuperView?.SendSubviewToBack (this);
|
|
SuperView?.SendSubviewToBack (this);
|