Class: Button

DKTools.Sprite.Button

Button class

new DKTools.Sprite.Button ()

Extends

Members

_align String privatereadonly inherited

_fillColor String | null privatereadonly inherited

_fixedBitmap Boolean privatereadonly inherited

_font Object privatereadonly inherited

_graphicFolder String privatereadonly inherited

_graphicLoadListener function privatereadonly inherited

_graphicName String privatereadonly inherited

_longPressInterval Number privatereadonly

_paintOpacity Number privatereadonly inherited

_textColor String privatereadonly inherited

align String readonly inherited

Text align

contents Bitmap | null inherited

Bitmap of the sprite To support functions from DKTools.Base

fillColor String | null readonly inherited

Fill color

font Object readonly inherited

Text font

graphicFolder String readonly inherited

Graphic folder

graphicName String readonly inherited

Graphic name

longPressInterval

Gets interval of long pressing

mousePressTime

Gets mouse press time

paintOpacity Number readonly inherited

Paint opacity

textColor String readonly inherited

Text color

touchPressTime

Gets touch press time

windowskin Bitmap | null readonly inherited

Window skin

Methods

_loadGraphic () private inherited

Loads the graphic (using graphic folder and graphic name)

canRedrawAll ()Boolean inherited

Returns true if the sprite can be updated and redrawn
Returns:
Type Description
Boolean Sprite can be updated and redrawn

changeFont (font) inherited

Changes the font of the bitmap
Name Type Description
font Object Text font
Name Type Description
fontFace String optional Font face
fontSize Number optional Font size
fontItalic Boolean optional Font italic

changePaintOpacity (paintOpacity) inherited

Changes the paint opacity of the bitmap
Name Type Description
paintOpacity Number Paint opacity

changeTextColor (textColor) inherited

Changes the text color of the bitmap
Name Type Description
textColor String Text color

createAll () inherited

Creates all objects

createBitmap () inherited

Loads an image by graphic name (if exists) or create the bitmap (if the fixed bitmap does not exist)

createTextBuffer (rtl)String inherited

Name Type Description
rtl Boolean
Returns:
Type Description
String

createTextState (text, x, y, width)Object inherited

Name Type Description
text String
x Number
y Number
width Number
Returns:
Type Description
Object

destroyBitmap ()Boolean inherited

Destroys the bitmap Return true if the bitmap destroyed
Returns:
Type Description
Boolean Bitmap destroyed

drawAll () inherited

Draws all

drawText (text, options)Boolean inherited

Draws a text Returns true if successfully completed
Name Type Default Description
text String Text
options Object {} optional Options for drawing
Name Type Description
font Object optional Use custom font
textColor String optional Use custom text color
paintOpacity Number optional Use custom paint opacity
align String optional Align
resetFont Boolean optional Use standard font after drawing the text
resetTextColor String optional Use standard text color after drawing the text
resetPaintOpacity String optional Use standard paint opacity after drawing the text
x Number optional The X coordinate
y Number | String optional The Y coordinate or line number (String)
width Number optional Width of the rectangle
height Number | String optional Height of the rectangle or number of lines (String)
pos Point | Object optional Position of the text (ignores other parameters of position: x, y)
rect Rectangle | Object optional Rectangle for drawing (ignores other parameters of position: x, y, width, height, pos)
pos.x Number optional The X coordinate
pos.y Number | String optional The Y coordinate or line number (String)
rect.x Number optional The X coordinate
rect.y Number | String optional The Y coordinate or line number (String)
rect.width Number | String optional Width of the rectangle
rect.height Number | String optional Height of the rectangle or number of lines (String)
Returns:
Type Description
Boolean Successfully completed
Example
var sprite = new DKTools.Sprite(0, 0, 100, 36);
sprite.start();
sprite.drawText('Text', { y: '1' });

flushTextState (textState) inherited

Name Type Description
textState Object

getLocalPoint (object, y)PIXI.Point inherited

Returns the local point (coordinates inside the sprite)
Name Type Description
object Number | Point | Object optional The X coordinate or Point or object with parameters
y Number optional The Y coordinate (if object is Number)
object.x Number optional The X coordinate
object.y Number optional The Y coordinate
Returns:
Type Description
PIXI.Point Local point (coordinates inside the sprite)

hasFillColor ()Boolean inherited

Returns true if the sprite has the fill color
Returns:
Type Description
Boolean Sprite has the fill color

hasFixedBitmap ()Boolean inherited

Returns true if the sprite has fixed bitmap (setted using setupBitmap or setBitmap)
Returns:
Type Description
Boolean Sprite has fixed bitmap (setted using setupBitmap or setBitmap)

hasGraphicFolder ()Boolean inherited

Returns true if the sprite has the graphic folder
Returns:
Type Description
Boolean Sprite has the graphic folder

hasGraphicName ()Boolean inherited

Returns true if the sprite has the graphic name
Returns:
Type Description
Boolean Sprite has the graphic name

initialize (object, y, width, height, object) inherited

Initializes a class object
Name Type Description
object Number | DKTools.Sprite | Bitmap | Rectangle | Object optional The X coordinate or Sprite or Bitmap or Rectangle or object with properties
y Number optional The Y coordinate (if object is Number)
width Number optional Width of the bitmap (if object is Number)
height Number optional Height of the bitmap (if object is Number)
object.x Number optional The X coordinate
object.y Number optional The Y coordinate
object.width Number optional Width of the bitmap
object.height Number optional Height of the bitmap
object Bitmap | Object optional Bitmap or object with parameters
Name Type Description
folder String Path to file
filename String Name of file
listener function optional Function of processing after loading a bitmap

isLongPressed ()Boolean

Returns true if the button is pressed longer than the long press interval
Returns:
Type Description
Boolean Button is pressed longer than the long press interval

isLongTouched ()Boolean

Returns true if touched longer than the long press interval
Returns:
Type Description
Boolean Touched longer than the long press interval

isPressed ()Boolean

Returns true if the button is pressed
Returns:
Type Description
Boolean Button is pressed

isResizable ()Boolean inherited

Returns true if you can change the size of the sprite
Returns:
Type Description
Boolean You can change the size of the sprite

isTouched ()Boolean

Returns true if touched
Returns:
Type Description
Boolean Touched

lineHeight ()Number inherited

Returns the height of the line
Returns:
Type Description
Number Height of the line

loadBitmap (object, filename, listener)Boolean inherited

Loads a bitmap Returns true if the bitmap has been changed
Name Type Description
object String | Object Path to file or object with parameters
filename String Name of file (if object is String)
listener function optional Function of processing after loading a bitmap (if object is String)
object.folder String Path to file
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
Returns:
Type Description
Boolean Bitmap has been changed

loadSystem (object, listener)Boolean inherited

Loads a bitmap from img/system/ Returns true if the bitmap has been changed
Name Type Description
object String | Object Name of file or object with parameters
listener function optional Function of processing after loading a bitmap (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
Returns:
Type Description
Boolean Bitmap has been changed

loadWindowskin (object, listener)Boolean inherited

Loads a window skin from img/system/ Returns true if the bitmap has been changed
Name Type Description
object String | Object Name of file or object with parameters
listener function optional Function of processing after loading a bitmap (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
Returns:
Type Description
Boolean Bitmap has been changed

moveWithAnchor (x, y) inherited

Moves the sprite (taking into account the anchor)
Name Type Description
x Number optional The X coordinate or Point or object with parameters
y Number | String optional The Y coordinate or line number (String) (if object is Number)
Version:
  • 1.1.0
Since:
  • 5.0.0

processAll ()

Processes all

processMousePress ()

Processes a mouse press

processTouch ()

Processes a touches

removeBitmap (destroy) inherited

Removes the bitmap
Name Type Default Description
destroy Boolean false optional Destroy the bitmap
Version:
  • 1.1.0

resetAll () inherited

Resets all

resetFont () inherited

Resets the font of the bitmap

resetFontSettings () inherited

Resets the font settings
Since:
  • 1.1.5

resetPaintOpacity () inherited

Resets the paint opacity of the bitmap

resetTextColor () inherited

Resets the text color of the bitmap

resize (width, height, blockStart)Boolean inherited

Changes the width and height of the sprite Returns true if the change occurred
Name Type Default Description
width Number Width of the sprite
height Number | String Height of the sprite or number of lines (String)
blockStart Boolean false optional Blocking the call of the "start" function
Version:
  • 1.1.5
Returns:
Type Description
Boolean Change occurred

setAlign (align, blockRefreshAll)Boolean inherited

Changes the align Returns true if the change occurred
Name Type Default Description
align String optional Text align
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setBitmap (object)Boolean inherited

Changes the bitmap Returns true if the change occurred
Name Type Description
object Bitmap | Object optional Bitmap or object with parameters
Name Type Description
folder String Path to file
filename String Name of file
listener function optional Function of processing after loading a bitmap
Returns:
Type Description
Boolean Change occurred

setFillColor (color, blockRefreshAll)Boolean inherited

Changes the fill color Returns true if the change occurred
Name Type Default Description
color String optional Fill color
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setFont (font, blockStart)Boolean inherited

Changes the font of the bitmap Returns true if the change occurred
Name Type Default Description
font Object optional Text font
blockStart Boolean false optional Blocking the call of the "start" function
font.fontFace String optional Font face
font.fontSize Number optional Font size
font.fontItalic Boolean optional Font italic
Returns:
Type Description
Boolean Change occurred

setGraphicFolder (folder, blockStart)Boolean inherited

Changes the graphic folder Returns true if the change occurred
Name Type Default Description
folder String optional Graphic folder
blockStart Boolean false optional Blocking the call of the "start" function
Returns:
Type Description
Boolean Change occurred

setGraphicName (graphicName, blockStart)Boolean inherited

Changes the graphic name Returns true if the change occurred
Name Type Default Description
graphicName String optional Graphic name
blockStart Boolean false optional Blocking the call of the "start" function
Returns:
Type Description
Boolean Change occurred

setPaintOpacity (opacity, blockRefreshAll)Boolean inherited

Changes the paint opacity Returns true if the change occurred
Name Type Default Description
opacity Number optional Paint opacity
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setTextColor (color, blockRefreshAll)Boolean inherited

Changes the text color Returns true if the change occurred
Name Type Default Description
color String optional Text color
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setupAlign (align) inherited

Sets the align
Name Type Default Description
align String this.standardAlign() optional Text align

setupAll (object) inherited overrides

Sets all parameters
Name Type Default Description
object Object {} optional Parameters
Name Type Description
longPressInterval Number optional Interval of long pressing
Version:
  • 1.1.0

setupAnchor (object, y) inherited

Sets the anchor of the sprite
Name Type Description
object Number | Point optional The X coordinate or Point
y Number optional The Y coordinate (if object is Number)
Version:
  • 1.1.0

setupBitmap (object) inherited

Sets the bitmap
Name Type Description
object Bitmap | Object optional Bitmap or object with parameters
Name Type Description
folder String Path to file
filename String Name of file
listener function optional Function of processing after loading a bitmap
hue Number optional Hue of bitmap
smooth Boolean optional Smooth of bitmap

setupFillColor (color) inherited

Sets the fill color
Name Type Description
color String optional Fill color

setupFont (font) inherited

Sets the font of the bitmap
Name Type Description
font Object optional Text font
Name Type Description
fontFace String optional Font face
fontSize Number optional Font size
fontItalic Boolean optional Font italic

setupFrame (object, y, width, height) inherited

Sets the frame of the sprite
Name Type Description
object Number | Rectangle optional The X coordinate or Rectangle
y Number optional The Y coordinate (if object is Number)
width Number optional Width of the frame (if object is Number)
height Number optional Height of the frame (if object is Number)
Version:
  • 1.1.0

setupGraphicFolder (folder) inherited

Sets the graphic folder
Name Type Description
folder String optional Path to folder

setupGraphicLoadListener (listener) inherited

Sets the listener on load of graphic
Name Type Description
listener function Listener

setupGraphicName (graphicName) inherited

Sets the graphic name
Name Type Description
graphicName String optional Graphic name

setupLongPressInterval (interval)

Sets the interval of long pressing
Name Type Default Description
interval Number this.standardLongPressInterval() optional Interval of long pressing

setupPaintOpacity (opacity) inherited

Sets the paint opacity
Name Type Description
opacity Number optional Paint opacity

setupSize (width, height) inherited

Sets the size of the bitmap
Name Type Description
width Number optional Width of the bitmap
height Number | String optional Height of the bitmap
Version:
  • 1.1.0

setupTextColor (color) inherited

Sets the color of the text
Name Type Description
color String optional Text color

standardActive ()Boolean

Returns the standard activity of the button
Returns:
Type Description
Boolean Standard activity of the button

standardAlign ()String inherited

Returns the standard text align
Returns:
Type Description
String Standard text align

standardAnchor ()Point inherited

Returns the standard anchor
Returns:
Type Description
Point Standard anchor

standardFillColor ()String | null inherited

Returns the standard fill color
Returns:
Type Description
String | null Standard fill color

standardFont ()Object inherited

Returns the standard font
Version:
  • 1.1.5
Returns:
Type Description
Object Standard font

standardFontBold ()Boolean inherited

Returns the standard font bold
Since:
  • 1.1.5
Returns:
Type Description
Boolean Standard font bold

standardFontFace ()String inherited

Returns the standard font face
Returns:
Type Description
String Standard font face

standardFontItalic ()Boolean inherited

Returns the standard font italic
Returns:
Type Description
Boolean Standard font italic

standardFontSize ()String inherited

Returns the standard font size
Returns:
Type Description
String Standard font size

standardFrame ()Rectangle inherited

Returns the standard frame
Returns:
Type Description
Rectangle Standard frame

standardGraphicFolder ()String inherited

Returns the standard graphic folder
Returns:
Type Description
String Standard graphic folder

standardGraphicName ()String inherited

Returns the standard graphic name
Returns:
Type Description
String standard graphic name

standardLongPressInterval ()Number

Returns the standard interval of long pressing
Returns:
Type Description
Number Standard interval of long pressing

standardPaintOpacity ()Number inherited

Returns the standard paint opacity
Returns:
Type Description
Number Standard paint opacity

standardTextColor ()String inherited

Returns the standard text color
Returns:
Type Description
String Standard text color

update () inherited overrides

Updates the button
Version:
  • 1.1.0

updateAll () inherited

Updates all

updateBitmap () inherited

Updates the bitmap

updateButtonState ()

Updates the button state

updateFill () inherited

Updates the fill of the sprite

updateFont (font) inherited

Updates the font of the bitmap
Name Type Default Description
font Object {} optional Text font
Name Type Description
fontFace String optional Font face
fontSize Number optional Font size
fontItalic Boolean optional Font italic

updateLongTouchEvents ()

Updates the events with type: long-touch

updateLongTouchFinishedEvents ()

Updates the events with type: mouse-long-press-finished

updateLongTouchStartedEvents ()

Updates the events with type: mouse-long-press-started

updateMouseClickEvents (button)

Updates the events with type: mouse-click-button
Name Type Description
button String Mouse button (left, middle or right)

updateMouseDownEvents (button)

Updates the events with type: mouse-down-button
Name Type Description
button String Mouse button (left, middle or right)

updateMouseLongPressEvents (button)

Updates the events with type: mouse-long-press-button
Name Type Description
button String Mouse button (left, middle or right)

updateMouseLongPressFinishedEvents (button)

Updates the events with type: mouse-long-press-button-finished
Name Type Description
button String Mouse button (left, middle or right)

updateMouseLongPressStartedEvents (button)

Updates the events with type: mouse-long-press-button-started
Name Type Description
button String Mouse button (left, middle or right)

updateMouseUpEvents (button)

Updates the events with type: mouse-up-button
Name Type Description
button String Mouse button (left, middle or right)

updatePaintOpacity (paintOpacity) inherited

Updates the paint opacity
Name Type Description
paintOpacity Number optional Paint opacity

updateStateNormalEvents ()

Updates the events with type: state-normal

updateStatePressedEvents ()

Updates the events with type: state-pressed

updateTextColor (textColor) inherited

Updates the text color
Name Type Description
textColor String optional Text color

updateTouchDownEvents ()

Updates the events with type: touch-down

updateTouchEvents ()

Updates the events with type: touch

updateTouchUpEvents ()

Updates the events with type: touch-up