mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Rename TextViewAutoComplete to ComboBox
This commit is contained in:
@@ -413,7 +413,7 @@ static class Demo {
|
||||
MessageBox.Query (60, 10, "Selected Animals", result == "" ? "No animals selected" : result, "Ok");
|
||||
}
|
||||
|
||||
static void TextFieldAutoCompleteDemo ()
|
||||
static void ComboBoxDemo ()
|
||||
{
|
||||
IList<string> items = new List<string> ();
|
||||
foreach (var dir in new [] { "/etc", @"\windows\System32" }) {
|
||||
@@ -425,7 +425,7 @@ static class Demo {
|
||||
.OrderBy (x => x).ToList ();
|
||||
}
|
||||
}
|
||||
var list = new TextFieldAutoComplete (0, 0, 36, 7, items);
|
||||
var list = new ComboBox (0, 0, 36, 7, items);
|
||||
list.Changed += (object sender, ustring text) => { Application.RequestStop (); };
|
||||
|
||||
var d = new Dialog ("Select source file", 40, 12) { list };
|
||||
@@ -563,7 +563,7 @@ static class Demo {
|
||||
new MenuBarItem ("_List Demos", new MenuItem [] {
|
||||
new MenuItem ("Select _Multiple Items", "", () => ListSelectionDemo (true)),
|
||||
new MenuItem ("Select _Single Item", "", () => ListSelectionDemo (false)),
|
||||
new MenuItem ("Search Single Item", "", TextFieldAutoCompleteDemo)
|
||||
new MenuItem ("Search Single Item", "", ComboBoxDemo)
|
||||
}),
|
||||
new MenuBarItem ("A_ssorted", new MenuItem [] {
|
||||
new MenuItem ("_Show text alignments", "", () => ShowTextAlignments ()),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// TextFieldAutoComplete.cs: TextField with AutoComplete
|
||||
// ComboBox.cs: ComboBox control
|
||||
//
|
||||
// Author:
|
||||
// Authors:
|
||||
// Ross Ferguson (ross.c.ferguson@btinternet.com)
|
||||
//
|
||||
|
||||
@@ -12,9 +12,9 @@ using NStack;
|
||||
|
||||
namespace Terminal.Gui {
|
||||
/// <summary>
|
||||
/// TextField with AutoComplete
|
||||
/// ComboBox control
|
||||
/// </summary>
|
||||
public class TextFieldAutoComplete : View {
|
||||
public class ComboBox : View {
|
||||
/// <summary>
|
||||
/// Changed event, raised when the selection has been confirmed.
|
||||
/// </summary>
|
||||
@@ -41,7 +41,7 @@ namespace Terminal.Gui {
|
||||
/// <param name="w">The width</param>
|
||||
/// <param name="h">The height</param>
|
||||
/// <param name="source">Auto completetion source</param>
|
||||
public TextFieldAutoComplete(int x, int y, int w, int h, IList<string> source)
|
||||
public ComboBox(int x, int y, int w, int h, IList<string> source)
|
||||
{
|
||||
listsource = new List<string>(source);
|
||||
height = h;
|
||||
@@ -55,7 +55,8 @@ namespace Terminal.Gui {
|
||||
ColorScheme = Colors.Dialog
|
||||
};
|
||||
listview.SelectedChanged += () => {
|
||||
SetValue (searchset [listview.SelectedItem]);
|
||||
if(searchset.Count > 0)
|
||||
SetValue (searchset [listview.SelectedItem]);
|
||||
};
|
||||
|
||||
Application.OnLoad += () => {
|
||||
@@ -90,6 +91,7 @@ namespace Terminal.Gui {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ProcessKey(KeyEvent e)
|
||||
{
|
||||
if (e.Key == Key.Tab)
|
||||
@@ -117,13 +119,13 @@ namespace Terminal.Gui {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.Key == Key.CursorDown && search.HasFocus && listview.SelectedItem == 0) { // jump to list
|
||||
if (e.Key == Key.CursorDown && search.HasFocus && listview.SelectedItem == 0 && searchset.Count > 0) { // jump to list
|
||||
this.SetFocus (listview);
|
||||
SetValue (searchset [listview.SelectedItem]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.Key == Key.CursorUp && listview.HasFocus && listview.SelectedItem == 0) // jump back to search
|
||||
if (e.Key == Key.CursorUp && listview.HasFocus && listview.SelectedItem == 0 && searchset.Count > 0) // jump back to search
|
||||
{
|
||||
search.CursorPosition = search.Text.Length;
|
||||
this.SetFocus (search);
|
||||
Reference in New Issue
Block a user