Instance Method

onExitCommand(perform:)

Sets up an action that triggers in response to receiving the exit command while the view has focus.

Declaration

func onExitCommand(perform action: (() -> Void)?) -> some View

Discussion

The user generates an exit command by pressing the Menu button on tvOS, or the escape key on macOS.

See Also

Handling View Events

func onAppear(perform: (() -> Void)?) -> View

Adds an action to perform when the view appears.

func onDisappear(perform: (() -> Void)?) -> View

Adds an action to perform when the view disappears.

func onCommand(Selector, perform: (() -> Void)?) -> View

Adds an action to perform in response to the given selector.

func onCopyCommand(perform: (() -> [NSItemProvider])?) -> View

Adds an action to perform in response to the system’s Copy command.

func onCutCommand(perform: (() -> [NSItemProvider])?) -> View

Adds an action to perform in response to the system’s Cut command.

func onDeleteCommand(perform: (() -> Void)?) -> View

Adds an action to perform in response to the system’s Delete command.

func onMoveCommand(perform: ((MoveCommandDirection) -> Void)?) -> View

Adds an action to perform in response to a move command, like when the user presses an arrow key on a Mac keyboard, or taps the edge of the Siri Remote when controlling an Apple TV.

func onPasteCommand(of: [String], perform: ([NSItemProvider]) -> Void) -> View

Adds an action to perform in response to the system’s Paste command.

func onPasteCommand<Payload>(of: [String], validator: ([NSItemProvider]) -> Payload?, perform: (Payload) -> Void) -> View

Adds an action to perform in response to the system’s Paste command with items that you validate.

func onPlayPauseCommand(perform: (() -> Void)?) -> View

Adds an action to perform in response to the system’s Play/Pause command.

func onReceive<P>(P, perform: (P.Output) -> Void) -> View

Adds an action to perform when this view detects data emitted by the given publisher.

struct SubscriptionView

A view that subscribes to a publisher with an action.