Class: Button

Button

Button

new GOWN.Button(theme, skinName)

The basic Button with 3 states (up, down and hover) and a label that is centered on it
Name Type Default Description
theme GOWN.Theme optional theme for the button
skinName String Button.SKIN_NAME optional name of the button skin

Extends

Members

static,readonlyGOWN.Button.DOWNString

Down state: mouse button is pressed or finger touches the screen

static,readonlyGOWN.Button.HOVERString

Hover state: mouse pointer hovers over the button (ignored on mobile)

static,readonlyGOWN.Button.OUTString

Out state: mouse pointer leaves the button (ignored on mobile)

static,readonlyGOWN.Button.SKIN_NAMEString

Default button skin name

static,readonlyGOWN.Button.TRIGGEREDString

Dispatched when the button is triggered.

static,readonlyGOWN.Button.UPString

Up state: mouse button is released or finger is removed from the screen

allowDestroyCachebool

Will destroy the skin cache when the skinable gets destroyed
Default Value:
  • true

currentStateString

The current state

enabledBoolean

Enables/Disables the control. (not implemented yet)

labelString

Create/Update the label of the button.

skinFallbackString

The fallback skin if the other skin does not exist (e.g. if a mobile theme that does not provide a "hover" state is used on a desktop system) (normally the default "up"-state skin)
Default Value:
  • 'up'

skinNameString

The skin name
Default Value:
  • Button.SKIN_NAME

Methods

inherited changeSkin(skin)

Remove old skin and add new one
Name Type Description
skin DisplayObject
Destroy the Skinable and empty the skin cache

inherited fromSkin(name, callback)

Get image from skin (will execute a callback with the loaded skin when it is loaded or call it directly when it already is loaded)
Name Type Description
name String name of the state
callback function callback that is executed if the skin is loaded

protectedhandleEvent(type)

Handle one of the mouse/touch events
Name Type Description
type one of the valid states

inherited mousePos(){PIXI.Point}

Get the local mouse position from PIXI.InteractionData
Returns:
Type Description
PIXI.Point

protectedonDown()

onDown callback

protectedonHover()

onHover callback

protectedonOut()

onOut callback

protectedonTouchMove()

onTouchMove callback

protectedonUp()

onUp callback

protectedpreloadSkins()

Initiate all skins first (to prevent flickering)

protectedredraw()

Update before draw call (position label)

setTheme(theme)

Change the theme
Name Type Description
theme GOWN.Theme the new theme

protectedskinLoaded(skin)

Skin has been loaded (see preloadSkins) and stored into the skinCache. add to container, hide and resize
Name Type Description
skin the loaded skin

protectedupdateDimensions()

Update width/height of the button

inherited updateTheme(data)

Overwrite data from theme for this specific component. (usable if you want to change e.g. background color based on selected items)
Name Type Description
data updated skin data