Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

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 (readonly, copy, nonatomic) NSString *_Nonnull name;

Swift

var name: String { get }

states

All states available to this button

Objective-C

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

Swift

var states: [SDLSoftButtonState] { get }

currentState

The name of the current state of this soft button

Objective-C

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

Swift

@NSCopying var currentState: SDLSoftButtonState { get }

currentStateSoftButton

Undocumented

Objective-C

@property (strong, nonatomic, readonly) SDLSoftButton *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 (readonly, strong, nonatomic)
    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

eventHandler

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

state

The single state of the button

-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