Class: TouchButton<P>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:180
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 Parameter | Default type |
|---|---|
P extends TouchButtonProps | TouchButtonProps |
Constructors
Constructor
new TouchButton<
P>(props):TouchButton<P>
Defined in: src/sdk/components/FSComponent.ts:73
Creates an instance of a DisplayComponent.
Parameters
| Parameter | Type | Description |
|---|---|---|
props | P | The propertis of the component. |
Returns
TouchButton<P>
Inherited from
Properties
context?
optionalcontext: [] =undefined
Defined in: src/sdk/components/FSComponent.ts:64
The context on this component, if any.
Inherited from
contextType?
readonlyoptionalcontextType: readonly [] =undefined
Defined in: src/sdk/components/FSComponent.ts:67
The type of context for this component, if any.
Inherited from
cssClassSet
protectedreadonlycssClassSet:SetSubject<string>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:192
cssClassSub?
protectedoptionalcssClassSub:Subscription
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:241
currentMousePosition
protectedreadonlycurrentMousePosition:Vec2
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:244
dragThresholdPxActual
protectedreadonlydragThresholdPxActual:number
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:248
focusOnDrag
protectedreadonlyfocusOnDrag:boolean
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:246
holdTickInterval
protectedholdTickInterval:null|Timeout=null
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:210
holdTimeSinceLastPress
protectedholdTimeSinceLastPress:number=0
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:213
inhibitOnDrag
protectedreadonlyinhibitOnDrag:boolean
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:247
inhibitOnDragAxisActual
protectedreadonlyinhibitOnDragAxisActual:"both"|"x"|"y"
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:249
isEnabled
protectedreadonlyisEnabled:Subscribable<boolean> |Subscribable<false> |Subscribable<true>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:199
isEnabledSub?
protectedoptionalisEnabledSub:Subscription
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:238
isHeld
protectedisHeld:boolean=false
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:208
isHighlighted
protectedreadonlyisHighlighted:Subscribable<boolean> |Subscribable<false> |Subscribable<true>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:200
isHighlightedSub?
protectedoptionalisHighlightedSub:Subscription
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:239
isPrimed
protectedisPrimed:boolean=false
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:207
isVisible
protectedreadonlyisVisible:Subscribable<boolean> |Subscribable<false> |Subscribable<true>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:201
isVisibleSub?
protectedoptionalisVisibleSub:Subscription
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:240
labelContent
protectedreadonlylabelContent:undefined|string|VNode|MappedSubscribable<string>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:203
lastHoldTickTime
protectedlastHoldTickTime:undefined|number=undefined
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:211
mouseClickPosition
protectedreadonlymouseClickPosition:Vec2
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:243
mouseDownListener()
protectedreadonlymouseDownListener: (e) =>void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:194
Responds to mouse down events on this button's root element.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | MouseEvent | The mouse event. |
Returns
void
mouseLeaveListener()
protectedreadonlymouseLeaveListener: (e) =>void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:196
Responds to mouse leave events on this button's root element.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | MouseEvent | The mouse event. |
Returns
void
mouseMoveListener()
protectedreadonlymouseMoveListener: (e) =>void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:197
Handle mouse moving after clicking.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | MouseEvent | The mouse event. |
Returns
void
mouseUpListener()
protectedreadonlymouseUpListener: () =>void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:195
Responds to mouse up events on this button's root element.
Returns
void
props
props:
P&ComponentProps
Defined in: src/sdk/components/FSComponent.ts:61
The properties of the component.
Inherited from
rootRef
protectedreadonlyrootRef:NodeReference<HTMLDivElement>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:190
totalHoldTime
protectedtotalHoldTime:number=0
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:212
RESERVED_CSS_CLASSES
protectedreadonlystaticRESERVED_CSS_CLASSES:Set<string>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:181
Methods
destroy()
destroy():
void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:545
Destroys this component.
Returns
void
Overrides
getContext()
protectedgetContext(context):never
Defined in: src/sdk/components/FSComponent.ts:106
Gets a context data subscription from the context collection.
Parameters
| Parameter | Type | Description |
|---|---|---|
context | never | The 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
getDragDistance()
protectedgetDragDistance():number
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:487
Get the distance that the mouse has been dragged on the correct axis.
Returns
number
The distance.
getReservedCssClasses()
protectedgetReservedCssClasses():ReadonlySet<string>
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:540
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:293
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()
protectedreadonlyholdTickFunc():void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:215
Returns
void
onAfterRender()
onAfterRender(
node):void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:253
A callback that is called after the component is rendered.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | VNode | The component's VNode. |
Returns
void
Overrides
DisplayComponent.onAfterRender
onBeforeRender()
onBeforeRender():
void
Defined in: src/sdk/components/FSComponent.ts:80
A callback that is called before the component is rendered.
Returns
void
Inherited from
DisplayComponent.onBeforeRender
onMouseDown()
protectedonMouseDown(e):void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:390
Responds to mouse down events on this button's root element.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | MouseEvent | The mouse event. |
Returns
void
onMouseLeave()
protectedonMouseLeave(e):void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:439
Responds to mouse leave events on this button's root element.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | MouseEvent | The mouse event. |
Returns
void
onMouseMove()
protectedonMouseMove(e):void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:460
Handle mouse moving after clicking.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | MouseEvent | The mouse event. |
Returns
void
onMouseUp()
protectedonMouseUp():void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:426
Responds to mouse up events on this button's root element.
Returns
void
onPressed()
protectedonPressed():void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:498
Responds to when this button is pressed.
Returns
void
render()
render():
VNode
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:503
Renders the component.
Returns
A JSX element to be rendered.
Overrides
renderLabel()
protectedrenderLabel():null|VNode
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:526
Renders this button's label.
Returns
null | VNode
This button's rendered label, or null if this button does not have a label.
setHeld()
protectedsetHeld(isHeld,endReason):void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:342
Sets the held state of this button.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
isHeld | boolean | undefined | The new held state. |
endReason | TouchButtonHoldEndReason | TouchButtonHoldEndReason.Unknown | The reason that the held state is set to false. Ignored if isHeld is true. Defaults to TouchButtonHoldEndReason.Unknown. |
Returns
void
setPrimed()
protectedsetPrimed(isPrimed):void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:312
Sets the primed state of this button.
Parameters
| Parameter | Type | Description |
|---|---|---|
isPrimed | boolean | The new primed state. |
Returns
void
simulatePressed()
simulatePressed(
ignoreDisabled):void
Defined in: src/garminsdk/components/touchbutton/TouchButton.tsx:302
Simulates this button being pressed. This will execute the onPressed() callback if one is defined.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
ignoreDisabled | boolean | false | Whether to simulate the button being pressed regardless of whether the button is disabled. Defaults to false. |
Returns
void