Button.js

Inherits from: CGUI.js

1 ) function: draw
2 ) function: setText
3 ) function: clearText
4 ) function: hideText
5 ) function: toString
6 ) function: setEvent
7 ) function: getEvent
8 ) function: toggleState
9 ) function: mousedown
10 ) function: enableToggle
11 ) function: mouseup
12 ) function: mouseout
13 ) function: select
14 ) function: deselect
15 ) function: disable
16 ) function: enable
17 ) function: mouseover


Object: Button

Object Description:
Example:
Inherits from: CGUI


Constructor: Button
  • Parameter
    : width - width of button
height - height of button
text - text to display in button
event - function to call on mousedown event

There is documentation/code mismatch


Method: setText
Description: Set the text for this Button
  • Parameter
    : text - the text to display on the button


Method: clearText
Description: Clear the text from a Button


Method: hideText
Description: Hide the text associated with this button


Method: toString
Description: Display the text associated with this button.
If there is no text associated it returns
"BUTTON"


Method: setEvent
Description: event that happens when this button is clicked
  • Parameter
    : event - the event
may be a function, an object or a string


Method: getEvent
Description: return event that happens when this button is clicked
  • Parameter
    : event - the event
may be a function, an object or a string


Method: toggleState
Description: toggleState is called when a mousedown event
occurs on this a "toggle" button
  • Parameter
    : evt - the event
Note: This function stops the event propagation so that
nothing underneath receives it


Method: mousedown
Description: mousedown function is called when a mousedown event
occurs on this object
  • Parameter
    : evt - the event
Note: This function stops the event propagation so that
nothing underneath receives it


Method: enableToggle
Description: makes the button element toggable, much
like a switch


Method: mouseup
Description: mouseup function is called when a mouseup event
occurs on this object
  • Parameter
    : evt - the event


Method: mouseout
Description: mouseout function is called when a mouseout event
occurs on this object
  • Parameter
    : evt - the event


Method: select
Description: Select this button
Changes the appearance to the "selected" state


Method: deselect
Description: Deselect this button


Method: disable
Description: disable this button
Changes the appearance to the "disable" state
Removes the mousedown event
Sets enabled to false


Method: enable
Description: enable this button
Changes the appearance to the enabled state
Restores the mousedown event
Sets enabled to true


Method: mouseover
Description: mouseover function is called when a mouseover event
occurs on this object
  • Parameter
    : evt - the event