Skip to content

Partial #2975 - Deprecate v1 Menu classes #4013

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

Open
wants to merge 109 commits into
base: v2_develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b0f050f
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 21, 2025
a64b4bc
touching publish.yml
tig Mar 21, 2025
320384e
Merge branch 'v2_release' into v2_develop
tig Mar 21, 2025
4048436
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Mar 29, 2025
3b0311d
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 29, 2025
ae79c48
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 30, 2025
1c39896
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 1, 2025
2cee67f
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 1, 2025
9560cf3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 2, 2025
0795dd1
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 2, 2025
ca11609
Fixed UICatalog bugs. Added fluent tests.
tig Apr 2, 2025
c761249
marked v1 menu stuff as obsolte
tig Apr 2, 2025
5805515
Tweaks.
tig Apr 2, 2025
a3e823d
fixed unit tests
tig Apr 2, 2025
ba7fb21
general messing around
tig Apr 2, 2025
366cd89
general messing around
tig Apr 2, 2025
5a26e60
Playing with Fluent
tig Apr 2, 2025
4baccd7
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 3, 2025
01b5266
ColorScheme tweaks
tig Apr 3, 2025
52f487d
WIP: ColorScheme tweaks
tig Apr 3, 2025
5986301
Playing with Fluent
tig Apr 3, 2025
dba8049
Merged from laptop
tig Apr 3, 2025
cf9c0d0
Merged from laptop2
tig Apr 3, 2025
60183fa
Hacky-ish fixes to:
tig Apr 3, 2025
869c02a
Fixed Region bug preventing menus without borders from working
tig Apr 3, 2025
57fc308
Tweaks
tig Apr 3, 2025
edd3b5a
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 4, 2025
9a2a7a4
Fixed a bunch of CM issues
tig Apr 4, 2025
9c53486
Fixed OoptionSelector
tig Apr 5, 2025
fd31f49
ip
tig Apr 5, 2025
dd6c6a7
FixedCM issues
tig Apr 5, 2025
aa83191
Fixed CM issues2
tig Apr 5, 2025
7d7ffad
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 5, 2025
c37210a
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 5, 2025
d4c8b87
Revert "FixedCM issues"
tig Apr 5, 2025
bce9c2e
Reverted stuff
tig Apr 5, 2025
7d22a14
Found and fixed bug in AllViews_Center_Properly
tig Apr 5, 2025
5ed311f
Merge branch 'v2_develop' into v2_2975-v1Menu-Obsolete
tig Apr 5, 2025
4c25418
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 5, 2025
2850f83
Fixed CM issues2
tig Apr 5, 2025
c4b14d4
removed menuv2 onapplied.
tig Apr 5, 2025
47ae0e0
changed test time out to see if it helkps with ubuntu fails
tig Apr 5, 2025
e54f610
reset app on fail?
tig Apr 5, 2025
11fb9cc
back to 1500ms
tig Apr 5, 2025
d8ca951
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 6, 2025
d367b18
Made StatusBar nullable.
tig Apr 6, 2025
79f782b
Code Cleanup.
tig Apr 6, 2025
df661ea
HexEditor Code Cleanup.
tig Apr 6, 2025
a7201a7
HexEditor Code Cleanup.
tig Apr 6, 2025
663ee34
Back to 3000ms. Sigh.
tig Apr 6, 2025
2706cff
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 6, 2025
ba59936
Trying different logic
tig Apr 6, 2025
a628349
Trying different logic2
tig Apr 6, 2025
82c89f9
Fixed potential crash in runlop
tig Apr 6, 2025
21039c3
Fixed potential crash in runlop2
tig Apr 6, 2025
b04f638
Tweaked Spinner stuff
tig Apr 6, 2025
6796bb4
Removed TabView from TextEffects scenario. Not needed and possible cu…
tig Apr 6, 2025
9d3a652
back to 2000ms
tig Apr 6, 2025
8c5d7ac
WIP: Revamping menu scenarios
tig Apr 6, 2025
0a4740c
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 7, 2025
114deee
Menu Scenario refinements.
tig Apr 7, 2025
81310ce
fixed unit test
tig Apr 7, 2025
7a39979
Fixed warnings
tig Apr 7, 2025
7f08306
Fixed warnings2
tig Apr 7, 2025
a433f5e
Fixed File.Exit
tig Apr 7, 2025
f759174
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 7, 2025
89a0093
WIP: Dealing with QuitKey struggles
tig Apr 8, 2025
824e4cf
WIP: Dealing with QuitKey struggles 2
tig Apr 11, 2025
cd9339c
Merge branch 'v2_develop' into v2_2975-v1Menu-Obsolete
tig Apr 16, 2025
8e9c8a3
WIP: Dealing with QuitKey struggles 3
tig Apr 16, 2025
2366242
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 16, 2025
680e5ae
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 16, 2025
92aae38
Fixed ListView collection nav bug
tig Apr 16, 2025
f7d498d
Fixed a bunch of menu stuff.
tig Apr 17, 2025
f276514
Lots of refactoring and fixing
tig Apr 18, 2025
af5e739
Lots of unit test issues
tig Apr 18, 2025
801f8de
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 19, 2025
95370e0
Fixed DebugIDisposable issues
tig Apr 19, 2025
4f5a020
Fixed release build issue
tig Apr 19, 2025
4d028eb
Fixed release build issue 2
tig Apr 19, 2025
9f0cf82
DebugIDisposable -> EnableDebugIDisposableAsserts and more
tig Apr 19, 2025
69bed23
DebugIDisposable -> EnableDebugIDisposableAsserts and more 2
tig Apr 19, 2025
198cc37
Fixed Menus scenario - context menu
tig Apr 20, 2025
091e716
Rethinking how submenus should be shown
tig Apr 20, 2025
3789c68
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 20, 2025
dc3dcd4
Refactoring Menuv2 etc... WIP - lots broken.
tig Apr 23, 2025
9f13868
Refactoring Menuv2 etc... WIP - lots broken.
tig Apr 23, 2025
e694b23
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 23, 2025
3cba0a5
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 23, 2025
9bbec08
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 24, 2025
64403fa
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 24, 2025
ac9c7f6
Merge branch 'v2_develop' into v2_2975-v1Menu-Obsolete
tig Apr 24, 2025
3431fe6
Merged. WIP - Very broken
tig Apr 24, 2025
5e1251c
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 24, 2025
49cd335
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 25, 2025
9a8e4e3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 25, 2025
ef6d193
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 25, 2025
785b266
Merge branch 'v2_develop' into v2_2975-v1Menu-Obsolete
tig Apr 25, 2025
4c0c504
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 25, 2025
4f5fca2
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 28, 2025
f8bfab8
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 28, 2025
898c2de
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 28, 2025
cd10bb3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig May 7, 2025
d412c00
Merge branch 'gui-cs:v2_develop' into v2_develop
tig May 9, 2025
66f2c62
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig May 11, 2025
abfa66a
Merge branch 'gui-cs:v2_develop' into v2_develop
tig May 11, 2025
d9dcca4
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig May 11, 2025
6757e2f
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig May 11, 2025
465fa65
Merged v2_develop
tig May 11, 2025
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
25 changes: 24 additions & 1 deletion Examples/UICatalog/Scenarios/Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ public override void Main ()
eventLog.MoveDown ();
};

menuHostView.Selecting += (o, args) =>
{
if (o is not View sender || args.Handled)
{
return;
}

Logging.Debug ($"{sender.Id} Selecting: {args?.Context?.Source?.Title}");
eventSource.Add ($"{sender.Id} Selecting: {args?.Context?.Source?.Title}: ");
eventLog.MoveDown ();
};

menuHostView.Accepting += (o, args) =>
{
if (o is not View sender || args.Handled)
Expand All @@ -75,6 +87,18 @@ public override void Main ()
eventLog.MoveDown ();
};

menuHostView.ContextMenu!.Selecting += (o, args) =>
{
if (o is not View sender || args.Handled)
{
return;
}

Logging.Debug ($"{sender.Id} Selecting: {args?.Context?.Source?.Title}");
eventSource.Add ($"{sender.Id} Selecting: {args?.Context?.Source?.Title}: ");
eventLog.MoveDown ();
};

menuHostView.ContextMenu!.Accepted += (o, args) =>
{
if (o is not View sender || args.Handled)
Expand Down Expand Up @@ -105,7 +129,6 @@ public MenuHost ()
{
CanFocus = true;
BorderStyle = LineStyle.Dashed;

AddCommand (
Command.Context,
ctx =>
Expand Down
6 changes: 3 additions & 3 deletions Terminal.Gui/Application/PopoverBaseImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ protected PopoverBaseImpl ()
ViewportSettings = ViewportSettings.Transparent | ViewportSettings.TransparentMouse;

// TODO: Add a diagnostic setting for this?
//TextFormatter.VerticalAlignment = Alignment.End;
//TextFormatter.Alignment = Alignment.End;
//base.Text = "popover";
TextFormatter.VerticalAlignment = Alignment.End;
TextFormatter.Alignment = Alignment.End;
base.Text = "PopoverBaseImpl";

AddCommand (Command.Quit, Quit);
KeyBindings.Add (Application.QuitKey, Command.Quit);
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Resources/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
"Glyphs.VLineHvDa3": "┇",
"Glyphs.VLineHvDa4": "┋"
}
},
},
{
"Dark": {
"Dialog.DefaultButtonAlignment": "End",
Expand Down
21 changes: 14 additions & 7 deletions Terminal.Gui/View/View.Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,24 @@ private void SetupCommands ()
Logging.Debug ($"{Title} ({ctx?.Source?.Title})");
CommandEventArgs args = new () { Context = ctx };

// Best practice is to invoke the virtual method first.
// This allows derived classes to handle the event and potentially cancel it.
if (OnSelecting (args) || args.Handled)
if (!args.Handled && Selecting is { })
{
return true;
// If the event is not canceled by the virtual method, raise the event to notify any external subscribers.
Logging.Debug ($"{Title} ({ctx?.Source?.Title}) - Raising Selecting...");
Selecting?.Invoke (this, args);
}

// If the event is not canceled by the virtual method, raise the event to notify any external subscribers.
Selecting?.Invoke (this, args);
// - bubbled up the SuperView hierarchy.
if (!args.Handled)
{
if (SuperView is { })
{
Logging.Debug ($"{Title} ({ctx?.Source?.Title}) - Invoking Select on SuperView ({SuperView.Title}/{SuperView.Id})...");
return SuperView?.InvokeCommand (Command.Select, ctx);
}
}

return Selecting is null ? null : args.Handled;
return args.Handled;
}

/// <summary>
Expand Down
7 changes: 7 additions & 0 deletions Terminal.Gui/View/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ public string Title
{
get
{
// TODO: Re-enable this after Debug logging in RaiseSelecting is removed
//#if DEBUG_IDISPOSABLE
// if (EnableDebugIDisposableAsserts && WasDisposed)
// {
// throw new ObjectDisposedException (GetType ().FullName);
// }
//#endif
return _title;
}
set
Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/Views/Menu/MenuBarv2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,12 @@
}

/// <inheritdoc/>
public bool EnableForDesign<TContext> (ref TContext context) where TContext : notnull

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / build_release

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / Parallel Unit Tests (macos-latest)

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / Parallel Unit Tests (ubuntu-latest)

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (macos-latest)

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / build_and_test_debug (ubuntu-latest)

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / Non-Parallel Unit Tests (ubuntu-latest)

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / Non-Parallel Unit Tests (windows-latest)

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.

Check warning on line 496 in Terminal.Gui/Views/Menu/MenuBarv2.cs

View workflow job for this annotation

GitHub Actions / Non-Parallel Unit Tests (macos-latest)

'MenuBarv2.EnableForDesign<TContext>(ref TContext)' hides inherited member 'Menuv2.EnableForDesign<TContext>(ref TContext)'. Use the new keyword if hiding was intended.
{
// Note: This menu is used by unit tests. If you modify it, you'll likely have to update
// unit tests.

Id = "DemonuBar";
Id = "DemoBar";

var bordersCb = new CheckBox
{
Expand Down Expand Up @@ -695,7 +695,7 @@

var editMode = new MenuItemv2
{
Text = "App Binding to Command.Edit",
Text = "Command = Edit; TargetView = null",
Id = "EditMode",
Command = Command.Edit,
CommandView = new CheckBox
Expand Down
64 changes: 40 additions & 24 deletions Terminal.Gui/Views/Menu/MenuItemv2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,40 @@ public Command Command

if (commandContext is CommandContext<KeyBinding> keyCommandContext)
{
if (SubMenu is { Visible: true } && (keyCommandContext.Command == Command.Select || keyCommandContext.Command == Command.Accept))
{
// Our submenu is open; and user pressed enter or clicked, set focus to it
Logging.Debug ($"{Title} - SubMenu is Visible; Accept/Select - {keyCommandContext.Command}");
SubMenu.SetFocus ();
return true;
}

if (SubMenu is { Visible: true } && keyCommandContext.Command == Command.HotKey)
{
// Our submenu is open; let command processing flow to it
Logging.Debug ($"{Title} - SubMenu Visible; HotKey - {keyCommandContext.Command}");
return false;
}

if (keyCommandContext.Binding.Key is { } && keyCommandContext.Binding.Key == Application.QuitKey && SuperView is { Visible: true })
{
// This supports a MenuItem with Key = Application.QuitKey/Command = Command.Quit
Logging.Debug ($"{Title} - Ignoring Key = Application.QuitKey/Command = Command.Quit");
quit = true;
//ret = true;
}
}

// Translate the incoming command to Command
if (Command != Command.NotBound && commandContext is { })
{
commandContext.Command = Command;
}

if (!quit)
{
if (TargetView is { })
{
Logging.Debug ($"{Title} - InvokeCommand on TargetView ({TargetView.Title})...");
// Translate the incoming command to Command
if (Command != Command.NotBound && commandContext is { })
{
commandContext.Command = Command;
}

Logging.Debug ($"{Title} - InvokeCommand on TargetView ({TargetView.Title}) - Command: {commandContext?.Command}...");
ret = TargetView.InvokeCommand (Command, commandContext);
}
else
Expand All @@ -143,35 +157,33 @@ public Command Command

if (ret is not true)
{
Logging.Debug ($"{Title} - calling base.DispatchCommand...");
Logging.Debug ($"{Title} - calling base.DispatchCommand. - Command: {commandContext?.Command}..");
// Base will Raise Selected, then Accepting, then invoke the Action, if any
ret = base.DispatchCommand (commandContext);
}

if (ret is true)
{
Logging.Debug ($"{Title} - Calling RaiseAccepted");
Logging.Debug ($"{Title} - Calling RaiseAccepted - Command: {commandContext?.Command}");
RaiseAccepted (commandContext);
}

return ret;
}

///// <inheritdoc />
//protected override bool OnAccepting (CommandEventArgs e)
//{
// Logging.Debug ($"{Title} - calling base.OnAccepting: {e.Context?.Command}");
// bool? ret = base.OnAccepting (e);

// if (ret is true || e.Cancel)
// {
// return true;
// }
/// <inheritdoc />
protected override bool OnAccepting (CommandEventArgs e)
{
Logging.Debug ($"{Title} - calling base.OnAccepting: {e.Context?.Command}");
bool? ret = base.OnAccepting (e);

// //RaiseAccepted (e.Context);
if (ret is true || e.Handled)
{
return true;
}

// return ret is true;
//}
return ret is true;
}

private Menuv2? _subMenu;

Expand All @@ -195,6 +207,7 @@ public Menuv2? SubMenu
}
}


/// <inheritdoc/>
protected override bool OnMouseEnter (CancelEventArgs eventArgs)
{
Expand Down Expand Up @@ -230,7 +243,10 @@ protected void RaiseAccepted (ICommandContext? ctx)
/// <remarks>
/// </remarks>
/// <param name="args"></param>
protected virtual void OnAccepted (CommandEventArgs args) { }
protected virtual void OnAccepted (CommandEventArgs args)
{
Logging.Debug ($"{Title} ({args.Context?.Command})");
}

/// <summary>
/// Raised when the user has accepted an item in this menu (or submenu). This is used to determine when to hide the
Expand Down
Loading
Loading