Documentation
    Preparing search index...

    Function collectFocusOrder

    • Collects the widgets Tab visits under root, in traversal order, into out, and returns it.

      The walk is collectPickables' walk, and prunes the same way: a subtree is skipped entirely at any node that is visible = false or enabled = false, so a hidden panel's buttons are not tabbable and a plain Group hides its UI descendants too. A surviving widget joins the order when it is focusable, enabled, not disabled, not disposed, and has not opted out with a negative tabIndex.

      Ascending accessibility.tabIndex (absent = 0), ties broken by scene order — which is what the stability of Array.prototype.sort gives, at no extra cost. Negative values are excluded from the traversal but stay focusable programmatically.

      The DOM instead visits positive tabindex values first, before everything at 0, and every accessibility guide since has told authors never to use a positive value because of it. That rule exists because HTML's tabindex must interleave with an implicit document order the attribute cannot see. Here the traversal order is the widget tree's own, the numbers are the only ordering an author can state, and a plain ascending sort is what tabIndex: 0, 1, 2 on three buttons plainly means. Stating the deviation is cheaper than importing a rule whose own designers regret it.

      Zero-alloc when out is supplied: it is overwritten, truncated, and sorted in place.

      Parameters

      Returns UIWidget[]