Files
Terminal.Gui/Examples/UICatalog/Scenarios/ViewExperiments.cs
Copilot e7a4df492d Fixes #4050. Rename Command.Select and Selecting to Activate/Activating (#4470)
* 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>
2025-12-09 12:42:34 -07:00

126 lines
3.2 KiB
C#

using System;
namespace UICatalog.Scenarios;
[ScenarioMetadata ("View Experiments", "v2 View Experiments")]
[ScenarioCategory ("Controls")]
[ScenarioCategory ("Adornments")]
[ScenarioCategory ("Layout")]
[ScenarioCategory ("Proof of Concept")]
public class ViewExperiments : Scenario
{
public override void Main ()
{
Application.Init ();
Window app = new ()
{
Title = GetQuitKeyAndName (),
TabStop = TabBehavior.TabGroup
};
var editor = new AdornmentsEditor
{
X = 0,
Y = 0,
TabStop = TabBehavior.NoStop,
AutoSelectViewToEdit = true,
ShowViewIdentifier = true
};
app.Add (editor);
FrameView testFrame = new ()
{
Title = "_1 Test Frame",
X = Pos.Right (editor),
Width = Dim.Fill (),
Height = Dim.Fill (),
};
app.Add (testFrame);
Button button = new ()
{
X = 0,
Y = 0,
Title = $"TopButton _{GetNextHotKey ()}",
};
testFrame.Add (button);
button = new ()
{
X = Pos.AnchorEnd (),
Y = Pos.AnchorEnd (),
Title = $"TopButton _{GetNextHotKey ()}",
};
var popoverView = new View ()
{
X = Pos.Center (),
Y = Pos.Center (),
Width = 30,
Height = 10,
Title = "Popover",
Text = "This is a popover",
Visible = false,
CanFocus = true,
Arrangement = ViewArrangement.Resizable | ViewArrangement.Movable
};
popoverView.BorderStyle = LineStyle.RoundedDotted;
Button popoverButton = new ()
{
X = Pos.Center (),
Y = Pos.Center (),
Title = $"_Close",
};
//popoverButton.Accepting += (sender, e) => App?.Popover!.Visible = false;
popoverView.Add (popoverButton);
button.Accepting += ButtonAccepting;
void ButtonAccepting (object sender, CommandEventArgs e)
{
//App?.Popover = popoverView;
//App?.Popover!.Visible = true;
}
testFrame.Activating += (sender, e) =>
{
if (e.Context is CommandContext<MouseBinding> { Binding.MouseEventArgs: { } mouseArgs })
{
if (mouseArgs.Flags == MouseFlags.Button3Clicked)
{
popoverView.X = mouseArgs.ScreenPosition.X;
popoverView.Y = mouseArgs.ScreenPosition.Y;
//App?.Popover = popoverView;
//App?.Popover!.Visible = true;
}
}
};
testFrame.Add (button);
editor.AutoSelectViewToEdit = true;
editor.AutoSelectSuperView = testFrame;
editor.AutoSelectAdornments = true;
Application.Run (app);
popoverView.Dispose ();
app.Dispose ();
Application.Shutdown ();
return;
}
private int _hotkeyCount;
private char GetNextHotKey ()
{
return (char)((int)'A' + _hotkeyCount++);
}
}