Skip to main content

Class: SetValueTouchButton<S>

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.

Type parameters

NameType
Sextends MutableSubscribable<any>

Hierarchy

  • DisplayComponent<SetValueTouchButtonProps<S>>

    SetValueTouchButton

Constructors

constructor

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

Creates an instance of a DisplayComponent.

Type parameters

NameType
Sextends MutableSubscribable<any, any>

Parameters

NameTypeDescription
propsSetValueTouchButtonProps<S>The propertis of the component.

Returns

SetValueTouchButton<S>

Inherited from

DisplayComponent<SetValueTouchButtonProps<S>>.constructor

Defined in

sdk/components/FSComponent.ts:73

Properties

buttonRef

Protected Readonly buttonRef: NodeReference<TouchButton<TouchButtonProps>>

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:103


context

Optional context: [] = undefined

The context on this component, if any.

Inherited from

DisplayComponent.context

Defined in

sdk/components/FSComponent.ts:64


contextType

Optional Readonly contextType: readonly [] = undefined

The type of context for this component, if any.

Inherited from

DisplayComponent.contextType

Defined in

sdk/components/FSComponent.ts:67


cssClassSet

Protected Readonly cssClassSet: SetSubject<string>

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:106


cssClassSub

Protected Optional cssClassSub: Subscription

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:116


props

props: SetValueTouchButtonProps<S> & ComponentProps

The properties of the component.

Inherited from

DisplayComponent.props

Defined in

sdk/components/FSComponent.ts:61


setValue

Protected Readonly setValue: Subscribable<SubscribableType<S>>

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:108


statusBarRef

Protected Readonly statusBarRef: NodeReference<ToggleStatusBar>

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:104


toggleState

Protected Readonly toggleState: MappedSubject<[any, SubscribableType<S>], boolean>

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:110


RESERVED_CSS_CLASSES

Static Protected Readonly RESERVED_CSS_CLASSES: Set<string>

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:101

Methods

destroy

destroy(): void

Returns

void

Inherit Doc

Overrides

DisplayComponent.destroy

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:243


getContext

getContext(context): never

Gets a context data subscription from the context collection.

Parameters

NameTypeDescription
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

Defined in

sdk/components/FSComponent.ts:106


getReservedCssClasses

getReservedCssClasses(): ReadonlySet<string>

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.

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:238


getRootElement

getRootElement(): HTMLElement

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.

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:123


onAfterRender

onAfterRender(node): void

A callback that is called after the component is rendered.

Parameters

NameTypeDescription
nodeVNodeThe component's VNode.

Returns

void

Inherited from

DisplayComponent.onAfterRender

Defined in

sdk/components/FSComponent.ts:87


onBeforeRender

onBeforeRender(): void

A callback that is called before the component is rendered.

Returns

void

Inherited from

DisplayComponent.onBeforeRender

Defined in

sdk/components/FSComponent.ts:80


onHoldEnded

onHoldEnded(button, totalHoldDuration, endReason): void

Responds to when this button exits the held state.

Parameters

NameTypeDescription
buttonTouchButton<TouchButtonProps>The 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

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:194


onHoldStarted

onHoldStarted(button): TouchButtonHoldAction

Responds to when this button enters the held state.

Parameters

NameTypeDescription
buttonTouchButton<TouchButtonProps>The button that is held.

Returns

TouchButtonHoldAction

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

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:167


onHoldTick

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

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

Parameters

NameTypeDescription
buttonTouchButton<TouchButtonProps>The 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.

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:182


onPressed

onPressed(button, isHeld): void

Responds to when this button is pressed.

Parameters

NameTypeDescription
buttonTouchButton<TouchButtonProps>The button that was pressed.
isHeldbooleanWhether the button was held when it was pressed.

Returns

void

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:153


onTouched

onTouched(button): TouchButtonOnTouchedAction

Responds to when this button is touched.

Parameters

NameTypeDescription
buttonTouchButton<TouchButtonProps>The button that was touched.

Returns

TouchButtonOnTouchedAction

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

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:142


render

render(): VNode

Returns

VNode

Inherit Doc

Overrides

DisplayComponent.render

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:199


simulatePressed

simulatePressed(ignoreDisabled?): void

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

Parameters

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

Returns

void

Defined in

garminsdk/components/touchbutton/SetValueTouchButton.tsx:132