Published release 0.2.1. Unreleased PR #2 reference.
LOOM 0.2.1 / COLLECTIONS AND INTERACTION
FocusState
Application-owned focus traversal, hit testing, and nested modal scopes.
Only the top scope participates in traversal or mouse focus. Pop a scope to restore
the previous focus. The caller still decides how to open/close dialogs and routes
events to focusedID; no event loop or action dispatch is owned by this type.
Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.
Members on this page
Feature guides and release status
FocusState
struct FocusState<ID> where ID : HashableConforms to: Swift.Sendable, Swift.SendableMetatype.
Application-owned focus traversal, hit testing, and nested modal scopes.
Only the top scope participates in traversal or mouse focus. Pop a scope to restore
the previous focus. The caller still decides how to open/close dialogs and routes
events to focusedID; no event loop or action dispatch is owned by this type.
wraps
var wraps: BoolA public field of this type. Its value type and mutability are shown in the declaration.
Source · FocusState.swift:26focusedID
var focusedID: ID? { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · FocusState.swift:27scopeDepth
var scopeDepth: Int { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · FocusState.swift:28init(_:focusedID:)
init(_ targets: [FocusTarget<ID>] = [], focusedID: ID? = nil)Creates a value with the supplied arguments. Default arguments are shown in the declaration.
Parameters (2)
targets- Argument type and any default are shown in the declaration; see the behavior notes above.
focusedID- Argument type and any default are shown in the declaration; see the behavior notes above.
update(_:)
mutating func update(_ targets: [FocusTarget<ID>])Reconciles the active scope after layout/data changes, skipping disabled targets.
Parameters (1)
targets- Argument type and any default are shown in the declaration; see the behavior notes above.
focus(_:)
@discardableResult mutating func focus(_ id: ID) -> BoolFocuses an enabled target in the current scope and returns whether a matching target exists.
Parameters (1)
id- Stable entry/icon identity, not an array index.
Returns Bool.
moveForward()
mutating func moveForward()Moves to the next enabled target in the active scope, respecting wraps.
Source · FocusState.swift:53moveBackward()
mutating func moveBackward()Moves to the previous enabled target in the active scope, respecting wraps.
Source · FocusState.swift:54pushScope(_:focusedID:)
mutating func pushScope(_ targets: [FocusTarget<ID>], focusedID: ID? = nil)Adds a nested set of focus targets, preserving the previous scope for restoration when popped.
Parameters (2)
targets- Argument type and any default are shown in the declaration; see the behavior notes above.
focusedID- Argument type and any default are shown in the declaration; see the behavior notes above.
popScope()
@discardableResult mutating func popScope() -> BoolReturns false at the root scope, which is never removed.
Returns Bool.
handle(_:)
@discardableResult mutating func handle(_ event: InputEvent) -> BoolHandles Tab, Shift-Tab, or a mouse press.
Dispatch a press to the newly focused control too.
Parameters (1)
event- Argument type and any default are shown in the declaration; see the behavior notes above.
Returns Bool.