- new (table class, float x,y,w,h, string caption, [Skin2D skin])
- returns: (Button)
creates a new Button object.
The Skin should have 8 states:
- button
- button_hover
- button_pressed
- button_hover_pressed
- button_focus
- button_focus_hover
- button_focus_pressed
- button_focus_hover_pressed
If no skin is passed the default skin is cloned.
- actionListeners
- {[table]} - a list of all actionlisteners
- addActionListener (function action,[string/any description])
- returns: ()
Adds a function that is called when the button is clicked. The
description is optionial. The action function
signature:
function actionfunction (buttonobject,datatable)
the datatable contains at index 1 the function and at index 2
the description. You can change the datatable in any way you want -
however, the function at index 1 will be the function that is being
called if an action occurs.
- clicked (Button self,wasmouse,wasdoubleclicked)
- returns: ()
called if the button was actually clicked. Is called
if the mouse is clicked, but can be called by other sources, too. Calls
all actionlistener functions. This method calls the actionlisteners.
Overload onClicked instead for simple use.
- dataButton
- {[table]} - the current state info of the button.
- dataButton.isFocusable
- {[boolean=true]} - can gain focus if true
- dataButton.mouseover
- {[boolean]} - true if the mouse is over the button
- dataButton.pressed
- {[boolean]} - true if the button is hold down
- dataButton.pressedMouseButton
- {[int]} - the mousebuttonid that holds the button down
- dataButton.pressedSince
- {[int]} - if button is pressed, this value stores the frame when the
mousebutton was pressed
- deleteVisibles (Button self)
- returns: ()
called when a
Component is no longer displayed
- getDoubleClickTriggerOnly (Button self)
- returns: (boolean)
returns true if the button is reacting only on double clicks
- hideVisibles (Button self)
- returns: ()
called when visible objects (l2ds) are no longer visible
- isFocusable (Component)
- returns: (boolean)
description from overloaded method of Component:
returns true if the component can be focused.
If you overload this method, please remember that you should return false
if your element is current not focusable, ie. if not visible or not enabled.
For example:
function TextField.isFocusable()
return true and self:isVisible()
end
- isPushButton (Button)
- returns: (boolean)
returns true if the Button is a pushbutton
- isPushed (Button)
- returns: (boolean)
returns true if the Button is pushed
- mouseEntered (Button self)
- returns: ()
sets mouseinside to true
- mouseExited (Button self)
- returns: ()
sets mouseinside and mousedown to false
- mouseMoved (Button self, MouseEvent e)
- returns: ()
called if the mouse actually moved over the button
- mousePressed (Button self, MouseEvent e)
- returns: ()
called if the mouse was pressed on the button
- mouseReleased (Button self, MouseEvent e)
- returns: ()
called if the mouse was released on the button
- onAction (Button self)
- returns: ()
calls directly clicked (invoked by actioncommands such
as ENTER on focused buttons
- onClicked (Button self, boolean state, wasmouse,wasdoubleclick)
- returns: ()
simple callback function that can be overloaded without
calling the superclass etc. Is called after all ActionListeners has been
processed. The state boolean flag is true if the button is currently pushed,
which matters only for pushable buttons - otherwise it is always false.
- positionUpdate (Button self)
- returns: ()
updates all the position info
- removeActionListener (function/any key)
- returns: ([function,description])
removes the actionlistener from the
object where the key can be the function or the description itself.
- setCustomL2d (Component self,[l2dnode, float x, y,z])
- returns: ([l2dnode])
set a custom
l2dnode for own purpose. The previously set custom
l2dnode is
deleted. The new customl2dnode ist also deleted if the button is deleted.
The new customl2dnode is returned by this function. If no
l2dnode is given,
the old customl2dnode is deleted.
- setDisplayable (Component self, boolean displayable)
- returns: ()
description from overloaded method of Component:
a displayable component should create all it needs to be displayed
(
l2dnodes & stuff).
- setDoubleClickTriggerOnly (Button self, boolean on)
- returns: ()
If set to true, the button reacts only on double clicks
- setIcon (texture/string icon, width,height,uvx,uvy,uvw,uvh, [blendmode])
- returns: ()
sets icon for the button. This is only a forwarder on the
Skin2D.setIcon
function and will throw an error if no skin is set for this button.
The default
blendmode is decal. If false is passed as
blendmode, no
blend is used.
- setPushState (Button,boolean)
- returns: ()
pass true if the button should be pushed. Setting
The pushstate won't affect actionlisteners and click functions.
- setPushable (Button, pushable, [state])
- returns: ()
Makes the button pushable. A pushbutton switches
between the normal and pressed state. You can use a third optional parameter
to set the state to an initial value.
- setText ()
- returns: ()
sets text of button
- setVisibility (Component self)
- returns: (boolean)
description from overloaded method of Component:
returns true if the component is
displayed (is actually on the rootpane) and is visible.
- toString (Button self)
- returns: ()
returns simple
string representation of the button