Class Widget.PushButton

Push Button Widget.

a button widget to be used within a Radio Group.

Usage:

     local dUI = require 'dmc_ui'
     local widget = dUI.newPushButton()

Properties

.x () set/get x position.
.y () set/get y position.
.width () set/get width.
.height () set/get height.
.anchorX () set/get anchorX.
.anchorY () set/get anchorY.
.backgroundStrokeWidth () set/get strokeWidth on background style.
.data () set/get user data for button.
.hitMarginX () set/get x-axis hit margin.
.hitMarginY () set/get y-axis hit margin.
.id () set/get button id.
.isActive () get button 'active' state.
.isEnabled () set/get whether button is 'disabled' or can be pressed/activated.
.isHitActive () set/get button press action.
.labelText () set/get text for button label.
.labelFont () set font to use for button label.
.labelFontSize () set font size to use for button label.
.onPress () set callback for onPress events.
.onRelease () set callback for onRelease events.
.onEvent () set callback for onEvent events.

Methods

Widget.PushButton:press () programmatically "press" a button.
Widget.PushButton:setBackgroundFillColor () set/get strokeWidth on background style.
Widget.PushButton:setHitMargin () set hit margin for button.
Widget.PushButton:setLabelTextColor () set text color for button label.


Properties

.x ()
set/get x position.

Usage:

  • widget.x = 5
  • print( widget.x )
.y ()
set/get y position.

Usage:

  • widget.y = 5
  • print( widget.y )
.width ()
set/get width.

Usage:

  • widget.width = 5
  • print( widget.width )
.height ()
set/get height.

Usage:

  • widget.height = 5
  • print( widget.height )
.anchorX ()
set/get anchorX.

Usage:

  • widget.anchorX = 5
  • print( widget.anchorX )
.anchorY ()
set/get anchorY.

Usage:

  • widget.anchorY = 5
  • print( widget.anchorY )
.backgroundStrokeWidth ()
set/get strokeWidth on background style. this is a convenience method for calling on background style.

Usage:

  • widget.backgroundStrokeWidth = 10
  • print( widget.backgroundStrokeWidth )
  •  (same as)
     print( widget.style.background.strokeWidth = 10 )
.data ()
set/get user data for button. convenient storage area for user data. this property is availble within button events.

Usage:

  • widget.data = 5
  • print( widget.data )
.hitMarginX ()
set/get x-axis hit margin. increases horizontal hit area for button, useful when button area is small. value must be greater or equal to 0.

Usage:

  • widget.hitMarginX = 5
  • print( widget.hitMarginX )
.hitMarginY ()
set/get y-axis hit margin. increases vertical hit area for button, useful when button area is small. value must be greater or equal to 0.

Usage:

  • widget.hitMarginY = 5
  • print( widget.hitMarginY )
.id ()
set/get button id. optional id value for button. this value is passed in during button events, making it easy to differentiate buttons.

Usage:

  • widget.id = 'left-button'
  • print( widget.id )
.isActive ()
get button 'active' state. check whether button is in 'active' state.

Usage:

    print( widget.isActive )
.isEnabled ()
set/get whether button is 'disabled' or can be pressed/activated. property to set button disabled state or to see if it's enabled. this sets both the look of the button and the button action. setting .isEnabled will also set .isHitActive accordingly.

Usage:

  • widget.isEnabled = false
  • print( widget.isEnabled )
.isHitActive ()
set/get button press action. this gets the action of the button, whether a press is handled or not. this property is also controlled by changes to .isEnabled.

Usage:

  • widget.isHitActive = false
  • print( widget.isHitActive )
.labelText ()
set/get text for button label.

Usage:

  • widget.labelText = "Press"
  • print( widget.labelText )
.labelFont ()
set font to use for button label.

Usage:

  • widget.labelFont = native.systemFont
  •  equivalent to:
     widget.style.label.font = native.systemFont
.labelFontSize ()
set font size to use for button label.

Usage:

  • widget.labelFontSize = 12
  •  equivalent to:
     widget.style.label.fontSize = 12
.onPress ()
set callback for onPress events.

Usage:

    widget.onPress = <function>
.onRelease ()
set callback for onRelease events.

Usage:

    widget.onRelease = <function>
.onEvent ()
set callback for onEvent events.

Usage:

    widget.onEvent = <function>

Methods

Widget.PushButton:press ()
programmatically "press" a button. this will fire both 'began' and 'ended' events.

Usage:

    widget:press()
Widget.PushButton:setBackgroundFillColor ()
set/get strokeWidth on background style. this is a convenience method for calling on background style.

Usage:

  • widget:setBackgroundFillColor( 1, 1, 1, 1 )
  •  equivalent to:
     widget.style.background.fillColor = { 1,1,1,1 }
Widget.PushButton:setHitMargin ()
set hit margin for button. this is a convenience method to set hit margins at same time. args can be two integers or a table as array. (there is no difference with this or the properties)

Usage:

  • print( widget:setHitMargin( 5, 0 ) )
  • print( widget:setHitMargin( { 2, 3 } ) )
Widget.PushButton:setLabelTextColor ()
set text color for button label. this is a convenience method to set the text color of the label

Usage:

     widget:setLabelTextColor( 1, 1, 1, 1 )
     equivalent to:
     widget.style.label.textColor = { 1,1,1,1 }
generated by LDoc 1.4.3 Last updated 2015-05-14 11:55:05