Skip to content

Struggling to understand the new TabStop functionality along with new Scrolling behavior #3831

@dasien

Description

@dasien

Hello,

I recently converted my application Retrowarden to the v2 Terminal GUI. Many improvements so i am very excited to see v2 continue to develop.

One major area of confusion i have is tab behavior and scrolling. I removed all the old ScrollBar code i had, but i am struggling to make scrolling work in the application. It would seem that in order to be compliant with "Keyboard Required" tenet, the appropriate place for me to handle the need to scroll to the control which is about to receive focus is the AdvanceFocus method? I want to make sure that the intention is for the developer to manage this via AdvanceFocus (or some other method/event), and not have it just be default behavior of the underlying system to make sure that the control with focus is visible. If the intention is for the developer to manage making sure the control that receives focus is viewable, I would really appreciate an example if possible, as i am struggling with making this work in v2.

As a precursor to that, however, is an understanding of how the new TabStop functionality is supposed to work. I have gone through my application's Views and set TabStop appropriately for all of them (I think). I have added them in the order in which i wanted them to be tabbed, even though there is no longer a way to set tab order directly. I still do not understand how the underlying system is
determining the order of tab navigation for views. Whenever i Tab through the controls, many are skipped and the order is not Top Left to Bottom Right as you would expect. To take advantage of the fact that my application has several common controls across detail input forms, i created the following structure.

+----------------------------+
+ Common Header Controls     +
+ (part of base class)       +
+----------------------------+
+----------------------------+
+ Custom Detail View         +
+ (part of derived class)    +
+----------------------------+
+----------------------------+
+ Common Footer Controls     +
+ (part of base class)       +
+----------------------------+

At runtime, depending on which type of item the user wants to add/edit, i swap in a "Detail View" of the appropriate type in the middle of the common header and footer controls. The Views contained in this Detail View never receive focus via a Tab key press. I suppose i could just create separate views for each item type and duplicate the common controls to get rid of the hierarchy, but i would prefer not to do that. I had a similar problem in V1, and the solution was for me to sprinkle in some calls to FocusFirst along with setting the TabOrder custom after the Views had all been assigned. I cannot set TabOrder any longer (the code is currently commented out in my project), so i am not sure how to get the application to consistently tab through the controls in the order that a user would expect. Even for those that it tabs to, the order kind of bounces around and is not in an order a user would expect.

Describe the solution you'd like
I would like to either understand how to make the current v2 tabbing system work, or have fine-grained control over the order in which the controls i place on the screen are tabbed. On the surface, the v1 solution of TabOrder made sense, but the underlying view composition didn't seem to respect those when you set them before the views were added at runtime, hence the need for me to go back with a custom method and override whatever the order was. I appreciate the new TabStop style, but without any way to directly influence the order in which the controls get focus, I don't know how to make that work.

For scrolling, just an example of how it is intended to work with keyboard events would be helpful. I don't see any other method in v2 that would be the appropriate place to check to see if a control is visible based on is x/y relative to the ViewPort other than AdvanceFocus (e.g. no Enter or GotFocus). An example that shows the intended behavior for an application to check a View's position relative to the visible part of the screen and what to call to advance the scrolling so that the control is visible would be great.

Thank you for all the great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    designIssues regarding Terminal.Gui design (bugs, guidelines, debates, etc...)

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions