Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComboBox multiple fixes #710

Merged
merged 42 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2833564
ComboBox multiple fixes. Dim.Fill() incorrectly calculated. List heig…
fergusonr Jun 20, 2020
a869b9c
Fixed AllViewsTester.cs crash
fergusonr Jun 20, 2020
e164ca2
Add constructor that takes a text argument
fergusonr Jun 20, 2020
cfcf8ef
ComboBox multiple fixes. Dim.Fill() incorrectly calculated. List heig…
fergusonr Jun 20, 2020
f3b1b07
Fixed AllViewsTester.cs crash
fergusonr Jun 20, 2020
6f97585
Add constructor that takes a text argument
fergusonr Jun 20, 2020
acacd0c
Accomodate upstream changes
fergusonr Jun 20, 2020
4938566
Merge branch 'combobox_fixes2' of https://github.com/fergusonr/gui.cs…
fergusonr Jun 20, 2020
4df3c4e
Fix unit test
fergusonr Jun 20, 2020
d11119a
Merge branch 'master' of https://github.com/migueldeicaza/gui.cs into…
fergusonr Jun 23, 2020
cd9e84b
ComboBox. Bracket single statements. Minor Re-factor
fergusonr Jun 23, 2020
1d859e3
Fixes #723 Views now are notified when they are added or removing.
BDisp Jun 23, 2020
5e2c949
Removing unnecessary base call.
BDisp Jun 24, 2020
81c4b3a
Made changes as suggested.
BDisp Jun 24, 2020
ecf9ba0
The current view is called once instead of being called for each SubV…
BDisp Jun 25, 2020
3d8ef9a
Rebase
fergusonr Jun 28, 2020
6d69099
Merge branch 'added-removing-view-events' of https://github.com/BDisp…
fergusonr Jun 28, 2020
ef3c020
ComboBox. Supports Unicode. Add dropdown arrow from @BDisp. Support P…
fergusonr Jun 28, 2020
92dda81
Removed Loaded event and changed LayoutComplete event.
BDisp Jun 29, 2020
0f4ddf4
Correct width/height
fergusonr Jun 30, 2020
6182eab
Fixes #723 Views now are notified when they are added or removing.
BDisp Jun 23, 2020
fa96f46
Removing unnecessary base call.
BDisp Jun 24, 2020
0d9b1d9
Made changes as suggested.
BDisp Jun 24, 2020
3eeb1d8
The current view is called once instead of being called for each SubV…
BDisp Jun 25, 2020
4790a52
ComboBox. Use SuperView to determine if control has been added to a c…
fergusonr Jun 30, 2020
e67ed2c
Merge branch 'master' of https://github.com/migueldeicaza/gui.cs into…
fergusonr Jun 30, 2020
cba29d6
Change from Adding to Added.
BDisp Jun 30, 2020
aaddcae
pull #724
fergusonr Jun 30, 2020
e0d50af
Accomodate changes for PR #724
fergusonr Jun 30, 2020
cffdba5
Added and Removing tests.
BDisp Jun 30, 2020
b99dbfe
ComboBox wire source directly to ListView
fergusonr Jul 1, 2020
f722f96
ComboBox. Allow user to set ColorScheme
fergusonr Jul 2, 2020
de5a30b
ComboBox hand pick @BDisp changes:-
fergusonr Jul 3, 2020
c71fad0
Merge branch 'master' of https://github.com/migueldeicaza/gui.cs into…
fergusonr Jul 3, 2020
8524009
Merge branch 'master' of https://github.com/migueldeicaza/gui.cs into…
fergusonr Jul 4, 2020
670595d
ComboBox. Use Clear() instead of Redraw()
fergusonr Jul 4, 2020
b9c8758
ComboBox. Adhere to ListView interface, added:-
fergusonr Jul 5, 2020
e8972f4
Changed to removed because it is safer to perform actions after delet…
BDisp Jul 5, 2020
e0c6067
Fixing the Removed test.
BDisp Jul 5, 2020
d464525
ComboBox. Wire-up Home/End keys down to listview
fergusonr Jul 6, 2020
3800a23
ComboBox. Fix #742
fergusonr Jul 6, 2020
7d8f3ca
Merge branch 'added-removing-view-events' of https://github.com/BDisp…
fergusonr Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Example/demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,20 +449,22 @@ static void ListSelectionDemo (bool multiple)

static void ComboBoxDemo ()
{
IList<string> items = new List<string> ();
foreach (var dir in new [] { "/etc", @"\windows\System32" }) {
//TODO: Duplicated code in ListsAndCombos.cs Consider moving to shared assembly
var items = new List<ustring> ();
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)
.Where (x => char.IsLetterOrDigit (x [0]))
.OrderBy (x => x).ToList ();
.OrderBy (x => x).Select (x => ustring.Make (x)).ToList ();
}
}
var list = new ComboBox () { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() };
list.SetSource(items.ToList());
list.SelectedItemChanged += (object sender, ustring text) => { Application.RequestStop (); };
var list = new ComboBox () { Width = Dim.Fill(), Height = Dim.Fill() };
list.SetSource(items);
list.OpenSelectedItem += (ListViewItemEventArgs text) => { Application.RequestStop (); };

var d = new Dialog ("Select source file", 40, 12) { list };
var d = new Dialog () { Title = "Select source file", Width = Dim.Percent (50), Height = Dim.Percent (50) };
d.Add (list);
Application.Run (d);

MessageBox.Query (60, 10, "Selected file", list.Text.ToString() == "" ? "Nothing selected" : list.Text.ToString(), "Ok");
Expand Down
30 changes: 30 additions & 0 deletions Terminal.Gui/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ internal enum Direction {

TextFormatter viewText;

/// <summary>
/// Event fired when a subview is being added to this view.
/// </summary>
public Action<View> Added;

/// <summary>
/// Event fired when a subview is being removed from this view.
/// </summary>
public Action<View> Removed;

/// <summary>
/// Event fired when the view gets focus.
/// </summary>
Expand Down Expand Up @@ -552,6 +562,7 @@ public virtual void Add (View view)
subviews = new List<View> ();
subviews.Add (view);
view.container = this;
OnAdded (view);
if (view.CanFocus)
CanFocus = true;
SetNeedsLayout ();
Expand Down Expand Up @@ -601,6 +612,7 @@ public virtual void Remove (View view)
var touched = view.Frame;
subviews.Remove (view);
view.container = null;
OnRemoved (view);

if (subviews.Count < 1)
this.CanFocus = false;
Expand Down Expand Up @@ -933,6 +945,24 @@ public FocusEventArgs () { }
public bool Handled { get; set; }
}

/// <summary>
/// Method invoked when a subview is being added to this view.
/// </summary>
/// <param name="view">The subview being added.</param>
public virtual void OnAdded (View view)
{
view.Added?.Invoke (this);
}

/// <summary>
/// Method invoked when a subview is being removed from this view.
/// </summary>
/// <param name="view">The subview being removed.</param>
public virtual void OnRemoved (View view)
{
view.Removed?.Invoke (this);
}

/// <inheritdoc/>
public override bool OnEnter ()
{
Expand Down
Loading