Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
iOS Documentation
SDLSoftButtonObject

SDLSoftButtonObject Class Reference

Section Contents

Overview

A soft button wrapper object that is capable of storing and switching between states

name

The name of this button

Objective-C

@property (nonatomic, copy, readonly) NSString *_Nonnull name;

Swift

var name: String { get }

states

All states available to this button

Objective-C

@property (nonatomic, strong, readonly) NSArray<SDLSoftButtonState *> *_Nonnull states;

Swift

var states: [SDLSoftButtonState] { get }

currentState

The name of the current state of this soft button

Objective-C

@property (nonatomic, copy, readonly) SDLSoftButtonState *_Nonnull currentState;

Swift

@NSCopying var currentState: SDLSoftButtonState { get }

currentStateSoftButton

Describes an on-screen button which may be presented in various contexts, e.g. templates or alerts

Objective-C

@property (nonatomic, strong, readonly) SDLSoftButton *_Nonnull currentStateSoftButton;

Swift

var currentStateSoftButton: SDLSoftButton { get }

eventHandler

The handler to be called when the button is in the current state and is pressed

Objective-C

@property (nonatomic, strong, readonly) SDLRPCButtonNotificationHandler _Nonnull eventHandler;

Swift

var eventHandler: SDLRPCButtonNotificationHandler { get }

-initWithName:states:initialStateName:handler:

Create a multi-state (or single-state, but you should use initWithName:state: instead for that case) soft button. For example, a button that changes its image or text, such as a repeat or shuffle button.

Objective-C

- (nonnull instancetype)
        initWithName:(nonnull NSString *)name
              states:(nonnull NSArray<SDLSoftButtonState *> *)states
    initialStateName:(nonnull NSString *)initialStateName
             handler:(nullable SDLRPCButtonNotificationHandler)eventHandler;

Swift

init(name: String, states: [SDLSoftButtonState], initialStateName: String, handler eventHandler: SDLRPCButtonNotificationHandler? = nil)

Parameters

name

The name of the button

states

The states available to the button

eventHandler

The handler to be called when the button is in the current state and is pressed

initialStateName

The first state to use

-initWithName:state:handler:

Create a single-state soft button. For example, a button that brings up a Perform Interaction menu.

Objective-C

- (nonnull instancetype)initWithName:(nonnull NSString *)name
                               state:(nonnull SDLSoftButtonState *)state
                             handler:(nullable SDLRPCButtonNotificationHandler)
                                         eventHandler;

Swift

init(name: String, state: SDLSoftButtonState, handler eventHandler: SDLRPCButtonNotificationHandler? = nil)

Parameters

name

The name of the button

state

The single state of the button

eventHandler

The handler to be called when the button is pressed

Return Value

The button object

-initWithName:text:artwork:handler:

Create a single-state soft button. For example, a button that brings up a Perform Interaction menu.

Objective-C

- (nonnull instancetype)initWithName:(nonnull NSString *)name
                                text:(nullable NSString *)text
                             artwork:(nullable SDLArtwork *)artwork
                             handler:(nullable SDLRPCButtonNotificationHandler)
                                         eventHandler;

Swift

init(name: String, text: String?, artwork: SDLArtwork?, handler eventHandler: SDLRPCButtonNotificationHandler? = nil)

Parameters

name

The name of the button

text

The text to be displayed on the button

artwork

The artwork to be displayed on the button

eventHandler

The handler to be called when the button is pressed

Return Value

The button object

-transitionToStateNamed:

Transition the soft button to another state in the states property. The wrapper considers all transitions valid (assuming a state with that name exists).

Warning

This method will throw an exception and crash your app (on purpose) if you attempt an invalid transition. So…don’t do that.

Objective-C

- (BOOL)transitionToStateNamed:(nonnull NSString *)stateName;

Swift

func transition(toState stateName: String) -> Bool

Parameters

stateName

The next state.

Return Value

YES if a state was found with that name, NO otherwise.

-transitionToNextState

Transition the soft button to the next state of the array set when in the states property

Objective-C

- (void)transitionToNextState;

Swift

func transitionToNextState()

-stateWithName:

Return a state from the state array with a specific name.

Objective-C

- (nullable SDLSoftButtonState *)stateWithName:(nonnull NSString *)stateName;

Swift

func state(withName stateName: String) -> SDLSoftButtonState?

Parameters

stateName

The name of the state to return

Return Value

The state, or nil if no state with that name exists

View on GitHub.com
Previous Section Next Section