mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Initial plan
* Rename Command.Select to Command.Activate and Selecting to Activating
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Add Activating event propagation to SuperView
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Update all comments and docs referencing Select to Activate
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Fix event log messages in examples to use Activating/Activate
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Revert automatic Activating event propagation that broke tests
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* Update docfx documentation to use Activate/Activating terminology
Co-authored-by: tig <585482+tig@users.noreply.github.com>
* renames
* Revert "Add Activating event propagation to SuperView"
This reverts commit 6d82bee9ad.
* added command diagrams
* mermaid
* updated level 3
* again
* Select->Activate in MouseTests.cs
* Update Terminal.Gui/Views/Selectors/FlagSelector.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor: Rename Selecting to Activating in View APIs
Renamed the `Selecting` event and `OnSelecting` method to
`Activating` and `OnActivating` to better reflect their purpose.
Updated all related comments, test method names, variables,
and assertions in `View` and `ViewCommandTests` to align with
the new terminology.
Improved code clarity by using `_` for unused parameters in
lambda expressions. Renamed properties like `HandleSelecting`
to `HandleActivating` and adjusted naming conventions for
consistency (e.g., `OnactivatingCount` to `OnActivatingCount`).
These changes enhance readability, maintainability, and
terminology consistency across the codebase.
* Update Terminal.Gui/Views/Selectors/OptionSelector.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Typos
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -159,7 +159,7 @@ public class KeyBindingsTests
|
||||
|
||||
view.HandlingHotKey += (s, e) => hotKeyRaised = true;
|
||||
view.Accepting += (s, e) => acceptRaised = true;
|
||||
view.Selecting += (s, e) => selectRaised = true;
|
||||
view.Activating += (s, e) => selectRaised = true;
|
||||
|
||||
Assert.Equal (KeyCode.T, view.HotKey);
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.T));
|
||||
|
||||
@@ -194,8 +194,8 @@ public class MouseEventRoutingTests (ITestOutputHelper output)
|
||||
|
||||
superView.Add (subView);
|
||||
|
||||
int selectingCount = 0;
|
||||
subView.Selecting += (_, _) => selectingCount++;
|
||||
int activatingCount = 0;
|
||||
subView.Activating += (_, _) => activatingCount++;
|
||||
|
||||
MouseEventArgs mouseEvent = new ()
|
||||
{
|
||||
@@ -207,7 +207,7 @@ public class MouseEventRoutingTests (ITestOutputHelper output)
|
||||
subView.NewMouseEvent (mouseEvent);
|
||||
|
||||
// Assert
|
||||
Assert.Equal (1, selectingCount);
|
||||
Assert.Equal (1, activatingCount);
|
||||
|
||||
subView.Dispose ();
|
||||
superView.Dispose ();
|
||||
@@ -395,7 +395,7 @@ public class MouseEventRoutingTests (ITestOutputHelper output)
|
||||
};
|
||||
|
||||
bool selectingCalled = false;
|
||||
view.Selecting += (_, _) => { selectingCalled = true; };
|
||||
view.Activating += (_, _) => { selectingCalled = true; };
|
||||
|
||||
MouseEventArgs mouseEvent = new ()
|
||||
{
|
||||
@@ -467,8 +467,8 @@ public class MouseEventRoutingTests (ITestOutputHelper output)
|
||||
|
||||
superView.Add (view);
|
||||
|
||||
int selectingCount = 0;
|
||||
view.Selecting += (_, _) => selectingCount++;
|
||||
int activatingCount = 0;
|
||||
view.Activating += (_, _) => activatingCount++;
|
||||
|
||||
MouseEventArgs mouseEvent = new ()
|
||||
{
|
||||
@@ -480,7 +480,7 @@ public class MouseEventRoutingTests (ITestOutputHelper output)
|
||||
view.NewMouseEvent (mouseEvent);
|
||||
|
||||
// Assert
|
||||
Assert.Equal (1, selectingCount);
|
||||
Assert.Equal (1, activatingCount);
|
||||
|
||||
view.Dispose ();
|
||||
superView.Dispose ();
|
||||
|
||||
@@ -11,7 +11,7 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
|
||||
{
|
||||
var testView = new View ();
|
||||
|
||||
Assert.Contains (MouseFlags.Button1Clicked, testView.MouseBindings.GetAllFromCommands (Command.Select));
|
||||
Assert.Contains (MouseFlags.Button1Clicked, testView.MouseBindings.GetAllFromCommands (Command.Activate));
|
||||
// Assert.Contains (MouseFlags.Button1DoubleClicked, testView.MouseBindings.GetAllFromCommands (Command.Accept));
|
||||
|
||||
Assert.Equal (5, testView.MouseBindings.GetBindings ().Count ());
|
||||
@@ -48,7 +48,7 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
|
||||
[InlineData (false, false, 1)]
|
||||
[InlineData (true, false, 1)]
|
||||
[InlineData (true, true, 1)]
|
||||
public void MouseClick_Raises_Selecting (bool canFocus, bool setFocus, int expectedSelectingCount)
|
||||
public void MouseClick_Raises_Activating (bool canFocus, bool setFocus, int expectedActivatingCount)
|
||||
{
|
||||
var superView = new View { CanFocus = true, Height = 1, Width = 15 };
|
||||
var focusedView = new View { CanFocus = true, Width = 1, Height = 1 };
|
||||
@@ -66,12 +66,12 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
|
||||
testView.SetFocus ();
|
||||
}
|
||||
|
||||
var selectingCount = 0;
|
||||
testView.Selecting += (sender, args) => selectingCount++;
|
||||
var activatingCount = 0;
|
||||
testView.Activating += (sender, args) => activatingCount++;
|
||||
|
||||
testView.NewMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked });
|
||||
Assert.True (superView.HasFocus);
|
||||
Assert.Equal (expectedSelectingCount, selectingCount);
|
||||
Assert.Equal (expectedActivatingCount, activatingCount);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
@@ -242,11 +242,11 @@ public class ViewCommandTests
|
||||
|
||||
#endregion Accepted tests
|
||||
|
||||
#region OnSelect/Select tests
|
||||
#region OnActivating/Activating tests
|
||||
|
||||
[Theory]
|
||||
[CombinatorialData]
|
||||
public void Select_Command_Raises_SetsFocus (bool canFocus)
|
||||
public void Activate_Command_Raises_SetsFocus (bool canFocus)
|
||||
{
|
||||
var view = new ViewEventTester
|
||||
{
|
||||
@@ -256,76 +256,76 @@ public class ViewCommandTests
|
||||
Assert.Equal (canFocus, view.CanFocus);
|
||||
Assert.False (view.HasFocus);
|
||||
|
||||
view.InvokeCommand (Command.Select);
|
||||
view.InvokeCommand (Command.Activate);
|
||||
|
||||
Assert.Equal (1, view.OnSelectingCount);
|
||||
Assert.Equal (1, view.OnActivatingCount);
|
||||
|
||||
Assert.Equal (1, view.SelectingCount);
|
||||
Assert.Equal (1, view.ActivatingCount);
|
||||
|
||||
Assert.Equal (canFocus, view.HasFocus);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Select_Command_Handle_OnSelecting_NoEvent ()
|
||||
public void Activate_Command_Handle_OnActivating_NoEvent ()
|
||||
{
|
||||
var view = new ViewEventTester ();
|
||||
Assert.False (view.HasFocus);
|
||||
|
||||
view.HandleOnSelecting = true;
|
||||
Assert.True (view.InvokeCommand (Command.Select));
|
||||
view.HandleOnActivating = true;
|
||||
Assert.True (view.InvokeCommand (Command.Activate));
|
||||
|
||||
Assert.Equal (1, view.OnSelectingCount);
|
||||
Assert.Equal (1, view.OnActivatingCount);
|
||||
|
||||
Assert.Equal (0, view.SelectingCount);
|
||||
Assert.Equal (0, view.ActivatingCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Select_Handle_Event_OnSelecting_Returns_True ()
|
||||
public void Activate_Command_Handle_Event_OnActivating_Returns_True ()
|
||||
{
|
||||
var view = new View ();
|
||||
var selectingInvoked = false;
|
||||
var activatingInvoked = false;
|
||||
|
||||
view.Selecting += ViewOnSelect;
|
||||
view.Activating += ViewOnActivating;
|
||||
|
||||
bool? ret = view.InvokeCommand (Command.Select);
|
||||
bool? ret = view.InvokeCommand (Command.Activate);
|
||||
Assert.True (ret);
|
||||
Assert.True (selectingInvoked);
|
||||
Assert.True (activatingInvoked);
|
||||
|
||||
return;
|
||||
|
||||
void ViewOnSelect (object? sender, CommandEventArgs e)
|
||||
void ViewOnActivating (object? sender, CommandEventArgs e)
|
||||
{
|
||||
selectingInvoked = true;
|
||||
activatingInvoked = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Select_Command_Invokes_Selecting_Event ()
|
||||
public void Activate_Command_Invokes_Activating_Event ()
|
||||
{
|
||||
var view = new View ();
|
||||
var selecting = false;
|
||||
var activating = false;
|
||||
|
||||
view.Selecting += ViewOnSelecting;
|
||||
view.Activating += ViewOnActivating;
|
||||
|
||||
view.InvokeCommand (Command.Select);
|
||||
Assert.True (selecting);
|
||||
view.InvokeCommand (Command.Activate);
|
||||
Assert.True (activating);
|
||||
|
||||
return;
|
||||
|
||||
void ViewOnSelecting (object? sender, CommandEventArgs e) { selecting = true; }
|
||||
void ViewOnActivating (object? sender, CommandEventArgs e) { activating = true; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MouseClick_Invokes_Select_Command ()
|
||||
public void MouseClick_Invokes_Activate_Command ()
|
||||
{
|
||||
var view = new ViewEventTester ();
|
||||
view.NewMouseEvent (new () { Flags = MouseFlags.Button1Clicked, Position = Point.Empty, View = view });
|
||||
|
||||
Assert.Equal (1, view.OnSelectingCount);
|
||||
Assert.Equal (1, view.OnActivatingCount);
|
||||
}
|
||||
|
||||
#endregion OnSelect/Select tests
|
||||
#endregion OnActivating/Activating tests
|
||||
|
||||
#region OnHotKey/HotKey tests
|
||||
|
||||
@@ -390,25 +390,25 @@ public class ViewCommandTests
|
||||
Id = "viewEventTester";
|
||||
CanFocus = true;
|
||||
|
||||
Accepting += (s, a) =>
|
||||
Accepting += (_, a) =>
|
||||
{
|
||||
a.Handled = HandleAccepted;
|
||||
AcceptedCount++;
|
||||
};
|
||||
|
||||
HandlingHotKey += (s, a) =>
|
||||
HandlingHotKey += (_, a) =>
|
||||
{
|
||||
a.Handled = HandleHandlingHotKey;
|
||||
HandlingHotKeyCount++;
|
||||
};
|
||||
|
||||
Selecting += (s, a) =>
|
||||
Activating += (_, a) =>
|
||||
{
|
||||
a.Handled = HandleSelecting;
|
||||
SelectingCount++;
|
||||
a.Handled = HandleActivating;
|
||||
ActivatingCount++;
|
||||
};
|
||||
|
||||
CommandNotBound += (s, a) =>
|
||||
CommandNotBound += (_, a) =>
|
||||
{
|
||||
a.Handled = HandleCommandNotBound;
|
||||
CommandNotBoundCount++;
|
||||
@@ -443,18 +443,18 @@ public class ViewCommandTests
|
||||
|
||||
public bool HandleHandlingHotKey { get; set; }
|
||||
|
||||
public int OnSelectingCount { get; set; }
|
||||
public int SelectingCount { get; set; }
|
||||
public bool HandleOnSelecting { get; set; }
|
||||
public bool HandleSelecting { get; set; }
|
||||
public int OnActivatingCount { get; set; }
|
||||
public int ActivatingCount { get; set; }
|
||||
public bool HandleOnActivating { get; set; }
|
||||
public bool HandleActivating { get; set; }
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool OnSelecting (CommandEventArgs args)
|
||||
protected override bool OnActivating (CommandEventArgs args)
|
||||
{
|
||||
OnSelectingCount++;
|
||||
OnActivatingCount++;
|
||||
|
||||
return HandleOnSelecting;
|
||||
return HandleOnActivating;
|
||||
}
|
||||
|
||||
public int OnCommandNotBoundCount { get; set; }
|
||||
|
||||
@@ -146,15 +146,15 @@ public class AllViewsTests (ITestOutputHelper output) : TestsAllViews
|
||||
designable.EnableForDesign ();
|
||||
}
|
||||
|
||||
var selectingCount = 0;
|
||||
view.Selecting += (s, e) => selectingCount++;
|
||||
var activatingCount = 0;
|
||||
view.Activating += (s, e) => activatingCount++;
|
||||
|
||||
var acceptedCount = 0;
|
||||
view.Accepting += (s, e) => { acceptedCount++; };
|
||||
|
||||
if (view.InvokeCommand (Command.Select) == true)
|
||||
if (view.InvokeCommand (Command.Activate) == true)
|
||||
{
|
||||
Assert.Equal (1, selectingCount);
|
||||
Assert.Equal (1, activatingCount);
|
||||
Assert.Equal (0, acceptedCount);
|
||||
}
|
||||
view?.Dispose ();
|
||||
@@ -178,15 +178,15 @@ public class AllViewsTests (ITestOutputHelper output) : TestsAllViews
|
||||
designable.EnableForDesign ();
|
||||
}
|
||||
|
||||
var selectingCount = 0;
|
||||
view.Selecting += (s, e) => selectingCount++;
|
||||
var activatingCount = 0;
|
||||
view.Activating += (s, e) => activatingCount++;
|
||||
|
||||
var acceptingCount = 0;
|
||||
view.Accepting += (s, e) => { acceptingCount++; };
|
||||
|
||||
if (view.InvokeCommand (Command.Accept) == true)
|
||||
{
|
||||
Assert.Equal (0, selectingCount);
|
||||
Assert.Equal (0, activatingCount);
|
||||
Assert.Equal (1, acceptingCount);
|
||||
}
|
||||
view?.Dispose ();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class CheckBoxTests ()
|
||||
ckb.CheckedStateChanging += (s, e) => checkedStateChangingCount++;
|
||||
|
||||
var selectCount = 0;
|
||||
ckb.Selecting += (s, e) => selectCount++;
|
||||
ckb.Activating += (s, e) => selectCount++;
|
||||
|
||||
var acceptCount = 0;
|
||||
ckb.Accepting += (s, e) => acceptCount++;
|
||||
@@ -250,7 +250,7 @@ public class CheckBoxTests ()
|
||||
checkBox.CheckedStateChanging += (s, e) => checkedStateChangingCount++;
|
||||
|
||||
var selectCount = 0;
|
||||
checkBox.Selecting += (s, e) => selectCount++;
|
||||
checkBox.Activating += (s, e) => selectCount++;
|
||||
|
||||
var acceptCount = 0;
|
||||
checkBox.Accepting += (s, e) => acceptCount++;
|
||||
@@ -292,7 +292,7 @@ public class CheckBoxTests ()
|
||||
checkBox.CheckedStateChanging += (s, e) => checkedStateChangingCount++;
|
||||
|
||||
var selectCount = 0;
|
||||
checkBox.Selecting += (s, e) => selectCount++;
|
||||
checkBox.Activating += (s, e) => selectCount++;
|
||||
|
||||
var acceptCount = 0;
|
||||
|
||||
|
||||
@@ -484,7 +484,7 @@ public class ShortcutTests
|
||||
};
|
||||
|
||||
var selected = 0;
|
||||
shortcut.Selecting += (s, e) => selected++;
|
||||
shortcut.Activating += (s, e) => selected++;
|
||||
|
||||
app.Keyboard.RaiseKeyDownEvent (key);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class TextFieldTests (ITestOutputHelper output) : FakeDriverBase
|
||||
{
|
||||
TextField tf = new ();
|
||||
|
||||
tf.Selecting += (sender, args) => Assert.Fail ("Selected should not be raied.");
|
||||
tf.Activating += (sender, args) => Assert.Fail ("Activating should not be raised.");
|
||||
|
||||
Runnable top = new ();
|
||||
top.Add (tf);
|
||||
@@ -64,15 +64,15 @@ public class TextFieldTests (ITestOutputHelper output) : FakeDriverBase
|
||||
{
|
||||
TextField tf = new ();
|
||||
|
||||
var selectingCount = 0;
|
||||
tf.Selecting += (sender, args) => selectingCount++;
|
||||
var activatingCount = 0;
|
||||
tf.Activating += (sender, args) => activatingCount++;
|
||||
|
||||
Runnable top = new ();
|
||||
top.Add (tf);
|
||||
tf.SetFocus ();
|
||||
top.NewKeyDownEvent (Key.Enter);
|
||||
|
||||
Assert.Equal (0, selectingCount);
|
||||
Assert.Equal (0, activatingCount);
|
||||
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user