diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs
index 3f6525740..4a5451003 100644
--- a/Terminal.Gui/Views/ComboBox.cs
+++ b/Terminal.Gui/Views/ComboBox.cs
@@ -9,6 +9,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
+
using NStack;
namespace Terminal.Gui {
@@ -43,9 +44,9 @@ namespace Terminal.Gui {
///
public void SetSource (IList source)
{
- if (source == null)
+ if (source == null) {
Source = null;
- else {
+ } else {
Source = MakeWrapper (source);
}
}
@@ -70,7 +71,7 @@ namespace Terminal.Gui {
///
/// Public constructor
///
- public ComboBox () : base()
+ public ComboBox () : base ()
{
search = new TextField ("");
listview = new ListView () { LayoutStyle = LayoutStyle.Computed, CanFocus = true };
@@ -126,16 +127,15 @@ namespace Terminal.Gui {
return new ListWrapper (source);
}
- private void Initialize()
+ private void Initialize ()
{
ColorScheme = Colors.Base;
search.TextChanged += Search_Changed;
- listview.OpenSelectedItem += (ListViewItemEventArgs a) => Selected();
+ listview.OpenSelectedItem += (ListViewItemEventArgs a) => Selected ();
// On resize
LayoutComplete += (LayoutEventArgs a) => {
-
search.Width = Bounds.Width;
listview.Width = autoHide ? Bounds.Width - 1 : Bounds.Width;
listview.Height = CalculatetHeight ();
@@ -143,8 +143,9 @@ namespace Terminal.Gui {
listview.SelectedItemChanged += (ListViewItemEventArgs e) => {
- if(searchset.Count > 0)
+ if (searchset.Count > 0) {
SetValue ((ustring)searchset [listview.SelectedItem]);
+ }
};
Application.Loaded += (Application.ResizedEventArgs a) => {
@@ -162,47 +163,72 @@ namespace Terminal.Gui {
listview.Y = Pos.Bottom (search);
- if (Width != null && width == 0) // new ComboBox() { Width =
+ if (Width != null && width == 0) { // new ComboBox() { Width =
width = Bounds.Width;
+ }
search.Width = width;
listview.Width = CalculateWidth ();
- if (Height != null && height == 0) // new ComboBox() { Height =
+ if (Height != null && height == 0) { // new ComboBox() { Height =
height = Bounds.Height;
+ }
listview.Height = CalculatetHeight ();
SetNeedsLayout ();
- if (this.Text != null)
+ if (this.Text != null) {
Search_Changed (Text);
+ }
- if (autoHide)
+ if (autoHide) {
listview.ColorScheme = Colors.Menu;
- else
+ } else {
search.ColorScheme = Colors.Menu;
+ }
};
search.MouseClick += Search_MouseClick;
- this.Add(listview, search);
- this.SetFocus(search);
+ this.Add (listview, search);
+ this.SetFocus (search);
}
- private void Search_MouseClick (MouseEventArgs e)
- {
- if (e.MouseEvent.Flags != MouseFlags.Button1Clicked)
- return;
+#if COMBO_FEATURE
+ bool isShow = false;
+#endif
+ private void Search_MouseClick (MouseEventArgs me)
+ {
+#if !COMBO_FEATURE
+
+ if (me.MouseEvent.Flags != MouseFlags.Button1Clicked)
+ return;
+#else
+ if (me.MouseEvent.X == Bounds.Right - 1 && me.MouseEvent.Y == Bounds.Top && me.MouseEvent.Flags == MouseFlags.Button1Pressed
+ && search.Text == "" && autoHide) {
+
+ if (isShow) {
+ HideList ();
+ isShow = false;
+ } else {
+ searchset = Source.ToList().Cast