Establishes a subscription to button notifications for HMI buttons. Buttons are not necessarily physical buttons, but can also be “soft” buttons on a touch screen, depending on the display in the vehicle. Once subscribed to a particular button, an application will receive both SDLOnButtonEvent and SDLOnButtonPress notifications whenever that button is pressed. The application may also unsubscribe from notifications for a button by invoking the SDLUnsubscribeButton operation
When a button is depressed, an SDLOnButtonEvent notification is sent to the application with a ButtonEventMode of BUTTONDOWN. When that same button is released, an SDLOnButtonEvent notification is sent to the application with a ButtonEventMode of BUTTONUP
When the duration of a button depression (that is, time between depression and release) is less than two seconds, an SDLOnButtonPress notification is sent to the application (at the moment the button is released) with a ButtonPressMode of SHORT. When the duration is two or more seconds, an SDLOnButtonPress notification is sent to the application (at the moment the two seconds have elapsed) with a ButtonPressMode of LONG
The purpose of SDLOnButtonPress notifications is to allow for programmatic detection of long button presses similar to those used to store presets while listening to the radio, for example
When a button is depressed and released, the sequence in which notifications will be sent to the application is as follows:
For short presses:
For long presses:
HMILevel needs to be FULL, LIMITED or BACKGROUND
Since SmartDeviceLink 1.0
See SDLUnsubscribeButton
Construct a SDLSubscribeButton with a handler callback when an event occurs.
- (nonnull instancetype)initWithHandler:
(nullable SDLRPCButtonNotificationHandler)handler;
init(handler: SDLRPCButtonNotificationHandler? = nil)
A callback that will be called when a button event occurs for the subscribed button.
An SDLSubscribeButton object
Construct a SDLSubscribeButton with a handler callback when an event occurs with a button name.
- (nonnull instancetype)
initWithButtonName:(nonnull SDLButtonName)buttonName
handler:(nullable SDLRPCButtonNotificationHandler)handler;
init(buttonName: SDLButtonName, handler: SDLRPCButtonNotificationHandler? = nil)
The name of the button to subscribe to
A callback that will be called when a button event occurs for the subscribed button
An SDLSubscribeButton object
A handler that will let you know when the button you subscribed to is selected.
Warning
This will only work if you use SDLManager.@property (nonatomic, copy) SDLRPCButtonNotificationHandler _Nonnull handler;
var handler: SDLRPCButtonNotificationHandler { get set }
The name of the button to subscribe to @discussion An enum value, see SDLButtonName
@property (nonatomic, strong) SDLButtonName _Nonnull buttonName;
var buttonName: SDLButtonName { get set }