Skip to main content

Class: SetValueTouchButton<S>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:100

A touchscreen button which displays whether the value of a bound state is equal to a set value. By default, pressing the button will apply its set value to the state. This behavior can be overridden by providing a custom callback function which runs when the button is pressed.

The root element of the button contains the touch-button-set-value CSS class by default, in addition to all root-element classes used by TouchButton.

The root element contains a child ToggleStatusBar component with the CSS class touch-button-set-value-status-bar and an optional label element with the CSS class touch-button-label.

Extends​

Type Parameters​

Type Parameter
S extends MutableSubscribable<any>

Constructors​

Constructor​

new SetValueTouchButton<S>(props): SetValueTouchButton<S>

Defined in: src/sdk/components/FSComponent.ts:76

Creates an instance of a DisplayComponent.

Parameters​

ParameterTypeDescription
propsSetValueTouchButtonPropsThe propertis of the component.

Returns​

SetValueTouchButton<S>

Inherited from​

DisplayComponent.constructor

Properties​

buttonRef​

protected readonly buttonRef: NodeReference<TouchButton<TouchButtonProps>>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:103


context?​

optional context: [] = undefined

Defined in: src/sdk/components/FSComponent.ts:67

The context on this component, if any.

Inherited from​

DisplayComponent.context


contextType?​

readonly optional contextType: readonly [] = undefined

Defined in: src/sdk/components/FSComponent.ts:70

The type of context for this component, if any.

Inherited from​

DisplayComponent.contextType


cssClassSet​

protected readonly cssClassSet: SetSubject<string>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:106


cssClassSub?​

protected optional cssClassSub: Subscription

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:116


props​

props: SetValueTouchButtonProps<S> & ComponentProps

Defined in: src/sdk/components/FSComponent.ts:64

The properties of the component.

Inherited from​

DisplayComponent.props


setValue​

protected readonly setValue: Subscribable<SubscribableType<S>>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:108


statusBarRef​

protected readonly statusBarRef: NodeReference<ToggleStatusBar>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:104


toggleState​

protected readonly toggleState: MappedSubject<[any, SubscribableType<S>], boolean>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:110


RESERVED_CSS_CLASSES​

protected readonly static RESERVED_CSS_CLASSES: Set<string>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:101

Methods​

destroy()​

destroy(): void

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:243

Destroys this component.

Returns​

void

Overrides​

DisplayComponent.destroy


getContext()​

protected getContext(context): never

Defined in: src/sdk/components/FSComponent.ts:109

Gets a context data subscription from the context collection.

Parameters​

ParameterTypeDescription
contextneverThe context to get the subscription for.

Returns​

never

The requested context.

Throws​

An error if no data for the specified context type could be found.

Inherited from​

DisplayComponent.getContext


getReservedCssClasses()​

protected getReservedCssClasses(): ReadonlySet<string>

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:238

Gets the CSS classes that are reserved for this button's root element.

Returns​

ReadonlySet<string>

The CSS classes that are reserved for this button's root element.


getRootElement()​

getRootElement(): HTMLElement

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:123

Gets this button's root HTML element.

Returns​

HTMLElement

This button's root HTML element.

Throws​

Error if this button has not yet been rendered.


onAfterRender()​

onAfterRender(node): void

Defined in: src/sdk/components/FSComponent.ts:90

A callback that is called after the component is rendered.

Parameters​

ParameterTypeDescription
nodeVNodeThe component's VNode.

Returns​

void

Inherited from​

DisplayComponent.onAfterRender


onBeforeRender()​

onBeforeRender(): void

Defined in: src/sdk/components/FSComponent.ts:83

A callback that is called before the component is rendered.

Returns​

void

Inherited from​

DisplayComponent.onBeforeRender


onHoldEnded()​

protected onHoldEnded(button, totalHoldDuration, endReason): void

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:194

Responds to when this button exits the held state.

Parameters​

ParameterTypeDescription
buttonTouchButtonThe button that was held.
totalHoldDurationnumberThe total amount of time, in milliseconds, that this button was held.
endReasonTouchButtonHoldEndReasonThe reason that this button exited the held state.

Returns​

void


onHoldStarted()​

protected onHoldStarted(button): TouchButtonHoldAction

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:167

Responds to when this button enters the held state.

Parameters​

ParameterTypeDescription
buttonTouchButtonThe button that is held.

Returns​

TouchButtonHoldAction

The action to take. Ignored if the value is equal to TouchButtonHoldAction.EndHold.


onHoldTick()​

protected onHoldTick(button, dt, totalTime, timeSinceLastPress): TouchButtonHoldAction

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:182

A callback which is called every frame when this button is held.

Parameters​

ParameterTypeDescription
buttonTouchButtonThe button that is held.
dtnumberThe elapsed time, in milliseconds, since the previous frame.
totalTimenumberThe total amount of time, in milliseconds, that this button has been held.
timeSinceLastPressnumberThe amount of time, in milliseconds, that this button has been held since the last time the button was pressed as a tick action.

Returns​

TouchButtonHoldAction

The action to take.


onPressed()​

protected onPressed(button, isHeld): void

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:153

Responds to when this button is pressed.

Parameters​

ParameterTypeDescription
buttonTouchButtonThe button that was pressed.
isHeldbooleanWhether the button was held when it was pressed.

Returns​

void


onTouched()​

protected onTouched(button): TouchButtonOnTouchedAction

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:142

Responds to when this button is touched.

Parameters​

ParameterTypeDescription
buttonTouchButtonThe button that was touched.

Returns​

TouchButtonOnTouchedAction

The action to take as a result of the button being touched.


render()​

render(): VNode

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:199

Renders the component.

Returns​

VNode

A JSX element to be rendered.

Overrides​

DisplayComponent.render


simulatePressed()​

simulatePressed(ignoreDisabled): void

Defined in: src/garminsdk/components/touchbutton/SetValueTouchButton.tsx:132

Simulates this button being pressed. This will execute the onPressed() callback if one is defined.

Parameters​

ParameterTypeDefault valueDescription
ignoreDisabledbooleanfalseWhether to simulate the button being pressed regardless of whether the button is disabled. Defaults to false.

Returns​

void