Table of Contents

Class FocusScrollHelper

Namespace
SharpConsoleUI.Helpers
Assembly
SharpConsoleUI.dll

Shared helpers for the focus scroll-into-view walk. When the focused control is nested deeper than a scroller's direct child (e.g. a button inside a non-scrolling CollapsiblePanel inside a ScrollablePanelControl), revealing the whole direct child is wrong: a tall direct child that already intersects the viewport is skipped by the "don't yank a spanning container to its top" guard, so the off-fold leaf is never revealed. These helpers compute the focused leaf's true row WITHIN the direct child so the scroller can reveal that row specifically.

public static class FocusScrollHelper
Inheritance
FocusScrollHelper
Inherited Members

Methods

TryGetFocusedRowInDirectChild(IWindowControl, IWindowControl, out int, out int)

Computes the vertical offset (in rows, from the direct child's top edge) of focused within directChild, and the focused control's height. Works even when focused is off-viewport and was therefore never painted (its ActualY is stale/zero): it arranges a transient copy of the direct child's own layout subtree at the direct child's actual on-screen size and reads the focused node's arranged bounds — the exact idiom used by CollapsiblePanel.FocusedChildOffsetInPanel for cursor placement, so the offset can never desync from where the body is actually laid out.

public static bool TryGetFocusedRowInDirectChild(IWindowControl directChild, IWindowControl focused, out int rowInChild, out int regionHeight)

Parameters

directChild IWindowControl

The scroller's direct child that contains the focused control.

focused IWindowControl

The focused control nested somewhere inside directChild.

rowInChild int

On success, the focused control's top row relative to the direct child's top.

regionHeight int

On success, the focused control's arranged height (at least 1).

Returns

bool

true if the offset was resolved from the layout subtree; otherwise false.