-
Notifications
You must be signed in to change notification settings - Fork 731
Preps for and partially Fixes #2491 - Refactors Toplevel and Application Navigation
#3634
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
Preps for and partially Fixes #2491 - Refactors Toplevel and Application Navigation
#3634
Conversation
Made Application #nullable enable
Still need to move navigation code out of Toplevel
…avigation static class).
|
The |
BDisp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that a Shortcut which now the StatusBar is using, must only have only a Key for each subview.
Yep. This is why I stopped and forked so I can take the time to make it right in the other PR. This does not effect use cases without nested TabGroups. |
Not sure what you mean. Regardless can you please open a separate issue? |
I wrote a unit tests with a status bar above that reproduces this. |
Great catch! Thank you! Here's a better, more focused unit test based on the one you provided. [Fact]
public void Changing_Key_Removes_Previous ()
{
var newActionCount = 0;
Shortcut shortcut = new Shortcut (Key.N.WithCtrl, "New", () => newActionCount++);
Application.Current = new Toplevel ();
Application.Current.Add (shortcut);
Assert.Equal (0, newActionCount);
Assert.True (Application.OnKeyDown (Key.N.WithCtrl));
Assert.False (Application.OnKeyDown (Key.W.WithCtrl));
Assert.Equal (1, newActionCount);
shortcut.Key = Key.W.WithCtrl;
Assert.False (Application.OnKeyDown (Key.N.WithCtrl));
Assert.True (Application.OnKeyDown (Key.W.WithCtrl));
Assert.Equal (2, newActionCount);
Application.Current.Dispose ();
} |
…:tig/Terminal.Gui into v2_2491-Refactor-TopLevel-Application-And-Focus
…:tig/Terminal.Gui into v2_2491-Refactor-TopLevel-Application-And-Focus
An even better version of the test: [Fact]
public void Key_Changing_Removes_Previous ()
{
Shortcut shortcut = new Shortcut ();
shortcut.Key = Key.A;
Assert.Contains (Key.A, shortcut.KeyBindings.Bindings.Keys);
shortcut.Key = Key.B;
Assert.DoesNotContain (Key.A, shortcut.KeyBindings.Bindings.Keys);
Assert.Contains (Key.B, shortcut.KeyBindings.Bindings.Keys);
} |
|
@tig after the creation of the IsTopLevel = _frmMenuDetails.CkbIsTopLevel?.State == CheckState.UnChecked,
HasSubMenu = _frmMenuDetails.CkbSubMenu?.State == CheckState.UnChecked,As you can see if any of the properties are |
I obviously made some mistakes. Not sure why you are commenting here instead of opening a new Issue though. |
Because their fix make more sense to be done in this branch as it has already fixes for shortcuts. But I'm still investigating why shortcuts menus aren't working on Window. |
Code cleanup
This is another PR paving the way for fixing
Toplevel- IntroduceRunnableandOverlappedinstead #2491It is a fork of the branch in
Focusworks #3627at the point where I had done a ton of refactoring, organization, code-clean up, and introduction of primitives required for #2491.
In order to prepare for addressing #2491 I moved a lot of code around here. In addition, I enabled nullability in big places, and re-organized
Viewas well asApplicationto make more understandable and maintainable. As a result, this PR is BIG.I want to get this merged because finishing #3627 is going to take a ton of work and I've been coding too much and need to take a break. At the same time, I don't want all the work I did to sit latent, especially since it moves a bunch of code around and will cause merge hell if not integrated quickly.
At the point where this PR's branch starts all unit tests pass and the new code paths are only active in these situations:
View.TabStopis set to something other thanTabBehavior.TabStopView.Arrangmentis set toViewArrangement.OverlappedFixes
ApplicationandToplevelcode without removing existingToplevelorOverlappedfunctionality.Application,ConsoleDriver, andToplevel#nullable enableViewArrangement.Overlappedand modifies navigation code to support overlapped views that have this flag set.TabBehaviorenum and changesView.TabStopto be of this type.View.Navigationwithout breaking existing functionality.TabandTab.WithShiftF6andF6.WithShift(matches Windows, should work on all platforms)Toplevel- IntroduceRunnableandOverlappedinstead #2491Proposed Changes/Todos
ConsoleDriveruse #nullable enableTopleveland intoApplication(viaApplicationNavigationstatic class)OverlappedTopnavigation out ofTopleveland intoApplicationOverlappedstatic classViewExperimentsbe a good scenario for exercising all of the above and other stuff for Master Issue: Get rid ofToplevel- IntroduceRunnableandOverlappedinstead #2491.For #3627 and beyond...
ViewArrangement.Overlappedwill work. UseTabIndexesand all theView.NextViewfocus stuff for navigation (instead of the code inOverlappedMoveNext). Use theSubviewordering (for just the subviews with ViewArrangement.Overlapped` set) to manage the z-order.IRunnableand replaceToplevelwith thatPull Request checklist:
CTRL-K-Dto automatically reformat your files before committing.dotnet testbefore commit///style comments)