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
Since:
  • 7.0.0

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
Since:
  • 9.0.0

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
Since:
  • 1.1.0
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
Version:
  • 10.0.0

createBitmap () inherited

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

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)
Version:
  • 6.3.0
Returns:
Type Description
Boolean Successfully completed
Example
var sprite = new DKTools.Sprite(0, 0, 100, 36);

sprite.start();

sprite.drawText('Text', { y: '1' });

getLocalPoint (object, y)PIXI.Point inherited

Returns the local point (coordinates inside the sprite)
Name Type Description
object Number | PIXI.Point | PIXI.ObservablePoint | 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
Since:
  • 8.0.0
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)
Since:
  • 1.1.0
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
hue Number optional Hue of bitmap
smooth Boolean optional Smooth of bitmap
Version:
  • 10.0.0

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
Since:
  • 9.0.0
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
Version:
  • 1.1.0
Returns:
Type Description
Boolean You can change the size of the sprite

isTouched ()Boolean

Returns true if touched
Since:
  • 9.0.0
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, hue, smooth)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)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of 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
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
Version:
  • 3.0.0
Returns:
Type Description
Boolean Bitmap has been changed

loadSystem (object, listener, hue, smooth)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)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
Returns:
Type Description
Boolean Bitmap has been changed

loadWindowskin (object, listener, hue, smooth)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)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of 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:
  • 10.0.0
Since:
  • 5.0.0

processAll ()

Processes all
Version:
  • 9.1.0

processMousePress ()

Processes a mouse press
Version:
  • 2.0.0

processTouch ()

Processes a touches
Since:
  • 9.0.0

removeBitmap () inherited

Removes the bitmap

reserveBitmap (object, filename, listener, hue, smooth, reservationId)Boolean inherited

Loads and reserves 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)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
reservationId Number optional Reservation ID (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
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
object.reservationId Number optional Reservation ID
Version:
  • 3.0.0
Returns:
Type Description
Boolean Bitmap has been changed

reserveSystem (object, listener, hue, smooth, reservationId)Boolean inherited

Loads and reserves 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)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
reservationId Number optional Reservation ID (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
object.reservationId Number optional Reservation ID
Version:
  • 3.0.0
Returns:
Type Description
Boolean Bitmap has been changed

resetAll () inherited

Resets all

resetFont () inherited

Resets the font of the bitmap

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:
  • 10.0.0
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
hue Number optional Hue of bitmap
smooth Boolean optional Smooth of 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:
  • 10.0.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:
  • 10.0.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
Version:
  • 10.0.0

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:
  • 10.0.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:
  • 10.0.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:
  • 10.0.5
Returns:
Type Description
Object Standard font

standardFontBold ()Boolean inherited

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

standardFontFace ()String inherited

Returns the standard font face
Version:
  • 8.2.0
Returns:
Type Description
String Standard font face

standardFontItalic ()Boolean inherited

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

standardFontSize ()Number inherited

Returns the standard font size
Version:
  • 8.2.0
Returns:
Type Description
Number Standard font size

standardFrame ()Rectangle inherited

Returns the standard frame
Version:
  • 8.0.0
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:
  • 10.0.0

updateAll () inherited

Updates all

updateBitmap () inherited

Updates the bitmap

updateButtonState ()

Updates the button state
Version:
  • 9.1.0

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
Since:
  • 9.0.0

updateLongTouchFinishedEvents ()

Updates the events with type: mouse-long-press-finished
Since:
  • 9.0.0

updateLongTouchStartedEvents ()

Updates the events with type: mouse-long-press-started
Since:
  • 9.0.0

updateMouseClickEvents (button)

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

updateMouseDownEvents (button)

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

updateMouseLongPressEvents (button)

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

updateMouseLongPressFinishedEvents (button)

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

updateMouseLongPressStartedEvents (button)

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

updateMouseUpEvents (button)

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

updatePaintOpacity (paintOpacity) inherited

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

updateStateNormalEvents ()

Updates the events with type: state-normal
Since:
  • 2.0.0

updateStatePressedEvents ()

Updates the events with type: state-pressed
Since:
  • 2.0.0

updateTextColor (textColor) inherited

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

updateTouchDownEvents ()

Updates the events with type: touch-down
Since:
  • 9.0.0

updateTouchEvents ()

Updates the events with type: touch
Since:
  • 9.0.0

updateTouchUpEvents ()

Updates the events with type: touch-up
Since:
  • 9.0.0