mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 07:47:54 +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:
@@ -106,7 +106,7 @@ public class MouseTests : TestsAllViews
|
||||
[InlineData (MouseFlags.Button2Clicked)]
|
||||
[InlineData (MouseFlags.Button3Clicked)]
|
||||
[InlineData (MouseFlags.Button4Clicked)]
|
||||
public void WantContinuousButtonPressed_True_Button_Clicked_Raises_Selecting (MouseFlags clicked)
|
||||
public void WantContinuousButtonPressed_True_Button_Clicked_Raises_Activating (MouseFlags clicked)
|
||||
{
|
||||
MouseEventArgs me = new ();
|
||||
|
||||
@@ -117,13 +117,13 @@ public class MouseTests : TestsAllViews
|
||||
WantContinuousButtonPressed = true
|
||||
};
|
||||
|
||||
var selectingCount = 0;
|
||||
var activatingCount = 0;
|
||||
|
||||
view.Selecting += (s, e) => selectingCount++;
|
||||
view.Activating += (s, e) => activatingCount++;
|
||||
|
||||
me.Flags = clicked;
|
||||
view.NewMouseEvent (me);
|
||||
Assert.Equal (1, selectingCount);
|
||||
Assert.Equal (1, activatingCount);
|
||||
|
||||
view.Dispose ();
|
||||
|
||||
|
||||
@@ -285,9 +285,9 @@ public class ButtonTests (ITestOutputHelper output)
|
||||
WantContinuousButtonPressed = true
|
||||
};
|
||||
|
||||
var selectingCount = 0;
|
||||
var activatingCount = 0;
|
||||
|
||||
button.Selecting += (s, e) => selectingCount++;
|
||||
button.Activating += (s, e) => activatingCount++;
|
||||
var acceptedCount = 0;
|
||||
|
||||
button.Accepting += (s, e) =>
|
||||
@@ -299,19 +299,19 @@ public class ButtonTests (ITestOutputHelper output)
|
||||
me = new ();
|
||||
me.Flags = pressed;
|
||||
button.NewMouseEvent (me);
|
||||
Assert.Equal (0, selectingCount);
|
||||
Assert.Equal (0, activatingCount);
|
||||
Assert.Equal (0, acceptedCount);
|
||||
|
||||
me = new ();
|
||||
me.Flags = released;
|
||||
button.NewMouseEvent (me);
|
||||
Assert.Equal (0, selectingCount);
|
||||
Assert.Equal (0, activatingCount);
|
||||
Assert.Equal (0, acceptedCount);
|
||||
|
||||
me = new ();
|
||||
me.Flags = clicked;
|
||||
button.NewMouseEvent (me);
|
||||
Assert.Equal (1, selectingCount);
|
||||
Assert.Equal (1, activatingCount);
|
||||
Assert.Equal (1, acceptedCount);
|
||||
|
||||
button.Dispose ();
|
||||
@@ -341,23 +341,23 @@ public class ButtonTests (ITestOutputHelper output)
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var selectingCount = 0;
|
||||
var activatingCount = 0;
|
||||
|
||||
button.Selecting += (s, e) =>
|
||||
button.Activating += (s, e) =>
|
||||
{
|
||||
selectingCount++;
|
||||
activatingCount++;
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
me.Flags = pressed;
|
||||
button.NewMouseEvent (me);
|
||||
Assert.Equal (0, acceptedCount);
|
||||
Assert.Equal (0, selectingCount);
|
||||
Assert.Equal (0, activatingCount);
|
||||
|
||||
me.Flags = released;
|
||||
button.NewMouseEvent (me);
|
||||
Assert.Equal (0, acceptedCount);
|
||||
Assert.Equal (0, selectingCount);
|
||||
Assert.Equal (0, activatingCount);
|
||||
|
||||
button.Dispose ();
|
||||
}
|
||||
|
||||
@@ -271,10 +271,10 @@ public class CheckBoxTests (ITestOutputHelper output)
|
||||
|
||||
ckb.CheckedState = initialState;
|
||||
|
||||
ckb.Selecting += OnActivating;
|
||||
ckb.Activating += OnActivating;
|
||||
|
||||
Assert.Equal (initialState, ckb.CheckedState);
|
||||
bool? ret = ckb.InvokeCommand (Command.Select);
|
||||
bool? ret = ckb.InvokeCommand (Command.Activate);
|
||||
Assert.True (ret);
|
||||
Assert.True (checkedInvoked);
|
||||
Assert.Equal (initialState, ckb.CheckedState);
|
||||
|
||||
@@ -69,9 +69,9 @@ public class ShortcutTests
|
||||
public void MouseClick_Default_CommandView_Raises_Accepted_Selected_Correctly (
|
||||
int mouseX,
|
||||
int expectedCommandViewAccepted,
|
||||
int expectedCommandViewSelected,
|
||||
int expectedCommandViewActivated,
|
||||
int expectedShortcutAccepted,
|
||||
int expectedShortcutSelected
|
||||
int expectedShortcutActivated
|
||||
)
|
||||
{
|
||||
Application.Begin (new Runnable<bool> ());
|
||||
@@ -85,13 +85,13 @@ public class ShortcutTests
|
||||
|
||||
var commandViewAcceptCount = 0;
|
||||
shortcut.CommandView.Accepting += (s, e) => { commandViewAcceptCount++; };
|
||||
var commandViewSelectCount = 0;
|
||||
shortcut.CommandView.Selecting += (s, e) => { commandViewSelectCount++; };
|
||||
var commandViewActivatingCount = 0;
|
||||
shortcut.CommandView.Activating += (s, e) => { commandViewActivatingCount++; };
|
||||
|
||||
var shortcutAcceptCount = 0;
|
||||
shortcut.Accepting += (s, e) => { shortcutAcceptCount++; };
|
||||
var shortcutSelectCount = 0;
|
||||
shortcut.Selecting += (s, e) => { shortcutSelectCount++; };
|
||||
shortcut.Activating += (s, e) => { shortcutSelectCount++; };
|
||||
|
||||
Application.TopRunnableView.Add (shortcut);
|
||||
Application.TopRunnableView.SetRelativeLayout (new (100, 100));
|
||||
@@ -105,9 +105,9 @@ public class ShortcutTests
|
||||
});
|
||||
|
||||
Assert.Equal (expectedShortcutAccepted, shortcutAcceptCount);
|
||||
Assert.Equal (expectedShortcutSelected, shortcutSelectCount);
|
||||
Assert.Equal (expectedShortcutActivated, shortcutSelectCount);
|
||||
Assert.Equal (expectedCommandViewAccepted, commandViewAcceptCount);
|
||||
Assert.Equal (expectedCommandViewSelected, commandViewSelectCount);
|
||||
Assert.Equal (expectedCommandViewActivated, commandViewActivatingCount);
|
||||
|
||||
Application.TopRunnableView.Dispose ();
|
||||
Application.ResetState (true);
|
||||
@@ -202,24 +202,24 @@ public class ShortcutTests
|
||||
var checkboxAccepted = 0;
|
||||
shortcut.CommandView.Accepting += (s, e) => { checkboxAccepted++; };
|
||||
|
||||
var checkboxSelected = 0;
|
||||
shortcut.CommandView.Selecting += (s, e) =>
|
||||
var checkboxActivated = 0;
|
||||
shortcut.CommandView.Activating += (s, e) =>
|
||||
{
|
||||
if (e.Handled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
checkboxSelected++;
|
||||
checkboxActivated++;
|
||||
};
|
||||
|
||||
Application.TopRunnableView.Add (shortcut);
|
||||
Application.TopRunnableView.SetRelativeLayout (new (100, 100));
|
||||
Application.TopRunnableView.LayoutSubViews ();
|
||||
|
||||
var selected = 0;
|
||||
shortcut.Selecting += (s, e) =>
|
||||
var activatingCount = 0;
|
||||
shortcut.Activating += (s, e) =>
|
||||
{
|
||||
selected++;
|
||||
activatingCount++;
|
||||
};
|
||||
|
||||
var accepted = 0;
|
||||
@@ -237,9 +237,9 @@ public class ShortcutTests
|
||||
});
|
||||
|
||||
Assert.Equal (expectedAccepted, accepted);
|
||||
Assert.Equal (expectedAccepted, selected);
|
||||
Assert.Equal (expectedAccepted, activatingCount);
|
||||
Assert.Equal (expectedCheckboxAccepted, checkboxAccepted);
|
||||
Assert.Equal (expectedCheckboxAccepted, checkboxSelected);
|
||||
Assert.Equal (expectedCheckboxAccepted, checkboxActivated);
|
||||
|
||||
Application.TopRunnableView.Dispose ();
|
||||
Application.ResetState (true);
|
||||
@@ -278,7 +278,7 @@ public class ShortcutTests
|
||||
shortcut.Accepting += (s, e) => accepted++;
|
||||
|
||||
var selected = 0;
|
||||
shortcut.Selecting += (s, e) => selected++;
|
||||
shortcut.Activating += (s, e) => selected++;
|
||||
|
||||
Application.RaiseKeyDownEvent (key);
|
||||
|
||||
|
||||
@@ -3048,7 +3048,7 @@ A B C
|
||||
dt.Rows.Add (1, 2, 3, 4, 5, 6);
|
||||
|
||||
tableView.MultiSelect = true;
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
|
||||
|
||||
Point selectedCell = tableView.GetAllSelectedCells ().Single ();
|
||||
Assert.Equal (0, selectedCell.X);
|
||||
@@ -3120,7 +3120,7 @@ A B C
|
||||
dt.Rows.Add (1, 2, 3, 4, 5, 6);
|
||||
tableView.FullRowSelect = true;
|
||||
tableView.MultiSelect = true;
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
|
||||
|
||||
// Toggle Select Cell 0,0
|
||||
tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.Space });
|
||||
@@ -3160,7 +3160,7 @@ A B C
|
||||
dt.Rows.Add (1, 2, 3, 4, 5, 6);
|
||||
dt.Rows.Add (1, 2, 3, 4, 5, 6);
|
||||
tableView.MultiSelect = true;
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
|
||||
|
||||
// Make a square selection
|
||||
tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.ShiftMask | KeyCode.CursorDown });
|
||||
@@ -3201,7 +3201,7 @@ A B C
|
||||
dt.Rows.Add (1, 2, 3, 4, 5, 6);
|
||||
dt.Rows.Add (1, 2, 3, 4, 5, 6);
|
||||
tableView.MultiSelect = true;
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
|
||||
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
|
||||
|
||||
// Make first square selection (0,0 to 1,1)
|
||||
tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.ShiftMask | KeyCode.CursorDown });
|
||||
|
||||
@@ -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