Skip to main content
With the Swift Concurrency API, your Rive view joins native focus navigation automatically when the graphic has focus nodes. The platform moves focus between views. Rive moves focus between elements in the graphic.

Native focus

Rive discovers focus nodes asynchronously after loading. The graphic can appear before the view can receive focus.
Native focus varies by platform. See Apple’s guidance for iPadOS 15 and later, tvOS, and visionOS and Mac Catalyst. iPhone offers Full Keyboard Access as a separate accessibility feature.
RiveUIViewRepresentable and AsyncRiveUIViewRepresentable become focusable automatically when the graphic is ready. Add either view directly to your SwiftUI hierarchy.

Requesting keyboard input

Keys go to the element that has focus, and the first element gets focus when the user navigates into the graphic, usually by pressing Tab. To send hardware-keyboard input to a graphic without that first Tab, such as WASD controls that work as soon as the graphic appears, make the view the keyboard responder. A request succeeds when the graphic is loaded, playing, in the key window, and has focus nodes. Rive then tries to focus the first element in the focus order, unless an element already has focus.
Requesting keyboard input doesn’t enable text input or show the software keyboard.
Call keyboardFocused(_:onResult:) on RiveUIViewRepresentable or AsyncRiveUIViewRepresentable, before any SwiftUI modifiers. The view waits until the graphic is ready before it makes the request.
Each change to true makes one request, and a change to false gives up keyboard input. To request again, such as after you replace the view’s content, set the value to false and then back to true in a later update.To learn whether an attempt succeeded, pass onResult. Rive calls it after each attempt with the action, .become or .resign, and whether it succeeded.A change to true while the view is paused makes no request. Pausing or removing the view, or a loading failure, cancels a pending request. Rive doesn’t call onResult in these cases.Avoid combining keyboardFocused(_:onResult:) with SwiftUI’s focused(_:) on the same view.
On iOS, iPadOS, visionOS, and Mac Catalyst, Tab and the arrow keys don’t move between elements until the view also has native focus. After you replace a view’s content, request keyboard input again.

Moving between elements

  • Tab and Shift+Tab follow the focus order set in the editor.
  • Arrow keys move focus in the direction you press.
  • On tvOS, the Siri Remote also moves focus. Rive treats the remote’s Select button as Enter. See Apple TV focus interactions.
Rive waits for the State Machine to handle each key before deciding whether to pass it back to the platform. Keyboard listeners get the key before focus navigation does. For example, if Rive leaves Tab unhandled at the last element, the platform can move focus to the next native control. Full Keyboard Access and gamepad navigation outside tvOS fall outside the Apple runtime’s focus support. Use Semantics for VoiceOver.