buttonRepeatBehavior
Sets whether buttons in this view should repeatedly trigger their actions on prolonged interactions.
Declaration
compose().buttonRepeatBehavior(
behavior: SwiftUI.ButtonRepeatBehavior
)nonisolated func buttonRepeatBehavior(
_ behavior: ButtonRepeatBehavior
) -> some ViewParameters
behavior*SwiftUI.ButtonRepeatBehaviorA value of
enabledmeans that buttons should enable repeating behavior and a value ofdisabledmeans that buttons should disallow repeating behavior.
Discussion
Apply this to buttons that increment or decrement a value or perform some other inherently iterative operation. Interactions such as pressing-and-holding on the button, holding the button's keyboard shortcut, or holding down the space key while the button is focused will trigger this repeat behavior.
Button {
playbackSpeed.advance(by: 1)
} label: {
Label("Speed up", systemImage: "hare")
}
.buttonRepeatBehavior(.enabled)This affects all system button styles, as well as automatically
affects custom ButtonStyle conforming types. This does not
automatically apply to custom PrimitiveButtonStyle conforming types,
and the EnvironmentValues.buttonRepeatBehavior value should be used
to adjust their custom gestures as appropriate.
See also
More in Input and interaction.
- allowsHitTestingConfigures whether this view participates in hit test operations.
- allowsWindowActivationEventsConfigures whether gestures in this view hierarchy can handle events that activate the containing window.
- disabledAdds a condition that controls whether someone can interact with this view.
- handlesExternalEventsSpecifies the external events that the view's scene handles if the scene is already open.
- helpAdds help text to a view using a localized string resource that you provide.
- invalidatableContentMark the receiver as their content might be invalidated.
- keyboardShortcutAssigns a keyboard shortcut to the modified control.
- scrollClipDisabledSets whether a scroll view clips its content to its bounds.
- scrollDisabledDisables or enables scrolling in scrollable views.
- scrollDismissesKeyboardConfigures the behavior in which scrollable content interacts with the software keyboard.
- sensoryFeedbackPlays the specified feedback when the provided trigger value changes.
- userActivityAdvertises a user activity type.