gui-cs / Terminal.Gui

Cross Platform Terminal UI toolkit for .NET
MIT License
9.55k stars 681 forks source link

Proposal: Focus/Navigation Changes - e.g. Remove `Tabindex` and `TabIndexes` in v2 #3669

Closed tig closed 2 weeks ago

tig commented 3 weeks ago

Remove Tabindex and TabIndexes in v2

Why?

If there are no objections, I am going to remove View.TabIndex and View.TabIndexes from Terminal.Gui v2 in #3627.

Questions

Q: What if I want to set the tab order? A: Simply re-order Subviews.

Q: Web frameworks have the concept. E.g. React. Are you sure you want to remove it? A: Yes, the same issues that plagued the original concept in Win32, then Winforms, then Xamarin, that are outlined in the Maui issue above apply to jQuery, React, etc...

Q: What about TabStop? A: The need indicates how a View behaves in keyboard navigation is real. I've already changed TabStop to be of type TabBehavior and I think that is still needed.

BDisp commented 3 weeks ago

No objections. Normally when we create an app using var sometimes we need to initialize a view to being referenced by another view, but we want the later view added to be tabbed first. But if we use private fields for views at class scope this isn't an issue.

tznind commented 3 weeks ago

Works for me!

tig commented 3 weeks ago

Rename Leave to Blur

Why?

I wrote this (in the new navigation.md doc) and after doing so was convinced we can do better:

Lexicon & Taxonomy

I did a bunch of research and other frameworks either:

We don't have a programming model that easily enables the former. So I want to swtich the the later.

Thoughts?

tig commented 3 weeks ago

I guess an alternative that would just avoid "leave"/"lost"/"blur" is to

hmmm....

tznind commented 3 weeks ago

Not a big fan of Blur as a word. To me that just sounds like someone heard Focus and thought of cameras lenses. To me a View gains and looses a thing. Or users input enters and leaves a view.

I don't mind the idea of a single event for focus change. And it's got the word focus in it so it won't be hard for api user to find

tig commented 3 weeks ago

Not a big fan of Blur as a word. To me that just sounds like someone heard Focus and thought of cameras lenses. To me a View gains and looses a thing. Or users input enters and leaves a view.

I don't mind the idea of a single event for focus change. And it's got the word focus in it so it won't be hard for api user to find

Ok, here's what I'd write in the migration guide:

BDisp commented 3 weeks ago

Just to alert that the Application.PrevTabStopKey which is the Key.Tab.WithShift won't work on Linux and that why it has an alternate key. Don't work on the TextView.

tig commented 3 weeks ago

Just to alert that the Application.PrevTabStopKey which is the Key.Tab.WithShift won't work on Linux and that why it has an alternate key. Don't work on the TextView.

Yep. Current migratingfrom v1.md in #3627 says the following. And this is all implemented in that PR:


In v1, the keys used for navigation were both hard-coded and configurable, but in an inconsistent way. Tab and Shift+Tab worked consistently for navigating between Subviews, but were not configurable. Ctrl+Tab and Ctrl+Shift+Tab navigated across Overlapped views and had configurable "alternate" versions (Ctrl+PageDown and Ctrl+PageUp).

In v2, this is made consistent and configurable:

F6 was chosen to match Windows

These keys are all registered as KeyBindingScope.Application key bindings by Application. Because application-scoped key bindings have the lowest priority, Views can override the behaviors of these keys (e.g. TextView overrides Key.Tab by default, enabling the user to enter \t into text). The AllViews_AtLeastOneNavKey_Leaves unit test ensures all built-in Views have at least one of the above keys that can advance.