Skip to content
pixi-silk
GitHub repository
Class

ButtonBlock

import { ButtonBlock } from 'pixi-silk/ui/blocks';

A button: a face that squishes on press, lights on hover, crossfades to its active colour and dims when disabled. Label and icon draw in the same call as the face.

Extends#

Constructors#

Constructor#

new ButtonBlock(options: ButtonBlockOptions): ButtonBlock;

Parameters#

ParameterType
optionsButtonBlockOptions

Returns#

ButtonBlock

Overrides#

Block.constructor

Properties#

PropertyModifierTypeDescriptionInherited fromDefined in
hpublicnumberHeight of the slot, design units. The layout sets it.Block.hpackages/pixi-silk/src/ui/blocks.ts:86
layerreadonlyBlockLayerThe layer it asked for. See BlockOptions.layer.Block.layerpackages/pixi-silk/src/ui/blocks.ts:88
wpublicnumberWidth of the slot, design units. The layout sets it.Block.wpackages/pixi-silk/src/ui/blocks.ts:84

Accessors#

surface#

Get Signature#

get surface(): BlockSurface | null;

The surface the block is in, or null.

Returns

BlockSurface | null

Inherited from#

Block.surface

Methods#

destroy()#

destroy(options?: DestroyOptions): void;

Stops following watched signals.

Parameters#

ParameterType
options?DestroyOptions

Returns#

void

Inherited from#

Block.destroy


layout()#

layout(style?: SmartLayout): SmartLayout;

The flex style of this block’s slot: its size, no shrinking, and an onSize that keeps w and h in step with the layout. An absolute slot stretched between two edges (inset, or left and right) takes its size from them instead. Pass it to add of a FlexContainer or SmartContainer.

Parameters#

ParameterType
styleSmartLayout

Returns#

SmartLayout

Inherited from#

Block.layout


paint()#

paint(
   g: SilkGraphics, 
   x: number, 
   y: number
): void;

Draws the block into g with its slot’s top-left corner at (x, y), in the surface’s space.

Parameters#

ParameterType
gSilkGraphics
xnumber
ynumber

Returns#

void

Overrides#

Block.paint


step()#

step(dt: number): boolean;

Advances the block’s springs by dt seconds. Returns true while any moves. Override it to animate something else, and return true while that runs.

Parameters#

ParameterType
dtnumber

Returns#

boolean

Inherited from#

Block.step


wake()#

wake(): void;

Asks the surface to repaint this block. The surface repaints until every block settles, then sleeps. The first call moves an 'auto' block to the live layer.

Returns#

void

Inherited from#

Block.wake