Skip to main content

Class: TouchButton<P>

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:181

A touchscreen button.

The root element of the button contains the touch-button CSS class by default. The root element also conditionally contains the touch-button-disabled, touch-button-primed, and touch-button-held classes when the button is disabled, primed, and held, respectively.

The root element optionally contains a child label element with the CSS class touch-button-label.

Extends​

Type Parameters​

Type ParameterDefault type
P extends TouchButtonPropsTouchButtonProps

Constructors​

Constructor​

new TouchButton<P>(props): TouchButton<P>

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

Creates an instance of a DisplayComponent.

Parameters​

ParameterTypeDescription
propsPThe propertis of the component.

Returns​

TouchButton<P>

Inherited from​

DisplayComponent.constructor

Properties​

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/TouchButton.tsx:193


cssClassSub?​

protected optional cssClassSub: Subscription

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:242


currentMousePosition​

protected readonly currentMousePosition: Vec2

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:245


dragThresholdPxActual​

protected readonly dragThresholdPxActual: number

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:249


focusOnDrag​

protected readonly focusOnDrag: boolean

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:247


holdTickInterval​

protected holdTickInterval: Timeout | null = null

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:211


holdTimeSinceLastPress​

protected holdTimeSinceLastPress: number = 0

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:214


inhibitOnDrag​

protected readonly inhibitOnDrag: boolean

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:248


inhibitOnDragAxisActual​

protected readonly inhibitOnDragAxisActual: "x" | "y" | "both"

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:250


isEnabled​

protected readonly isEnabled: Subscribable<boolean> | Subscribable<false> | Subscribable<true>

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:200


isEnabledSub?​

protected optional isEnabledSub: Subscription

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:239


isHeld​

protected isHeld: boolean = false

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:209


isHighlighted​

protected readonly isHighlighted: Subscribable<boolean> | Subscribable<false> | Subscribable<true>

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:201


isHighlightedSub?​

protected optional isHighlightedSub: Subscription

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:240


isPrimed​

protected isPrimed: boolean = false

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:208


isVisible​

protected readonly isVisible: Subscribable<boolean> | Subscribable<false> | Subscribable<true>

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:202


isVisibleSub?​

protected optional isVisibleSub: Subscription

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:241


labelContent​

protected readonly labelContent: string | VNode | MappedSubscribable<string> | undefined

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:204


lastHoldTickTime​

protected lastHoldTickTime: number | undefined = undefined

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:212


mouseClickPosition​

protected readonly mouseClickPosition: Vec2

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:244


mouseDownListener()​

protected readonly mouseDownListener: (e) => void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:195

Responds to mouse down events on this button's root element.

Parameters​

ParameterTypeDescription
eMouseEventThe mouse event.

Returns​

void


mouseLeaveListener()​

protected readonly mouseLeaveListener: (e) => void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:197

Responds to mouse leave events on this button's root element.

Parameters​

ParameterTypeDescription
eMouseEventThe mouse event.

Returns​

void


mouseMoveListener()​

protected readonly mouseMoveListener: (e) => void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:198

Handle mouse moving after clicking.

Parameters​

ParameterTypeDescription
eMouseEventThe mouse event.

Returns​

void


mouseUpListener()​

protected readonly mouseUpListener: () => void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:196

Responds to mouse up events on this button's root element.

Returns​

void


props​

props: P & ComponentProps

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

The properties of the component.

Inherited from​

DisplayComponent.props


rootRef​

protected readonly rootRef: NodeReference<HTMLDivElement>

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:191


totalHoldTime​

protected totalHoldTime: number = 0

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:213


RESERVED_CSS_CLASSES​

protected readonly static RESERVED_CSS_CLASSES: Set<string>

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

Methods​

destroy()​

destroy(): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:546

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


getDragDistance()​

protected getDragDistance(): number

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:488

Get the distance that the mouse has been dragged on the correct axis.

Returns​

number

The distance.


getReservedCssClasses()​

protected getReservedCssClasses(): ReadonlySet<string>

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:541

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/TouchButton.tsx:294

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.


holdTickFunc()​

protected readonly holdTickFunc(): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:216

Returns​

void


onAfterRender()​

onAfterRender(node): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:254

A callback that is called after the component is rendered.

Parameters​

ParameterTypeDescription
nodeVNodeThe component's VNode.

Returns​

void

Overrides​

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


onMouseDown()​

protected onMouseDown(e): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:391

Responds to mouse down events on this button's root element.

Parameters​

ParameterTypeDescription
eMouseEventThe mouse event.

Returns​

void


onMouseLeave()​

protected onMouseLeave(e): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:440

Responds to mouse leave events on this button's root element.

Parameters​

ParameterTypeDescription
eMouseEventThe mouse event.

Returns​

void


onMouseMove()​

protected onMouseMove(e): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:461

Handle mouse moving after clicking.

Parameters​

ParameterTypeDescription
eMouseEventThe mouse event.

Returns​

void


onMouseUp()​

protected onMouseUp(): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:427

Responds to mouse up events on this button's root element.

Returns​

void


onPressed()​

protected onPressed(): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:499

Responds to when this button is pressed.

Returns​

void


render()​

render(): VNode

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:504

Renders the component.

Returns​

VNode

A JSX element to be rendered.

Overrides​

DisplayComponent.render


renderLabel()​

protected renderLabel(): VNode | null

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:527

Renders this button's label.

Returns​

VNode | null

This button's rendered label, or null if this button does not have a label.


setHeld()​

protected setHeld(isHeld, endReason): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:343

Sets the held state of this button.

Parameters​

ParameterTypeDefault valueDescription
isHeldbooleanundefinedThe new held state.
endReasonTouchButtonHoldEndReasonTouchButtonHoldEndReason.UnknownThe reason that the held state is set to false. Ignored if isHeld is true. Defaults to TouchButtonHoldEndReason.Unknown.

Returns​

void


setPrimed()​

protected setPrimed(isPrimed): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:313

Sets the primed state of this button.

Parameters​

ParameterTypeDescription
isPrimedbooleanThe new primed state.

Returns​

void


simulatePressed()​

simulatePressed(ignoreDisabled): void

Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:303

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