Difference between revisions of "LGUI2:button"

From Lavish Software Wiki
Jump to: navigation, search
(Examples)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
A LavishGUI 2 button element is a standard [[LGUI2:Content Container|Content Container]] element, with the added behavior of accepting Keyboard Focus when clicked.
+
A [[LavishGUI 2]] button element is a standard [[LGUI2:Content Container|Content Container]] element, which can be "Pressed" in various ways (such as a mouse click), usually to activate some behavior.
  
 
== Defining a button element ==
 
== Defining a button element ==
A button element is a [[LGUI2:Content Container|Content Container]] with no additional properties.  
+
A button element is a [[LGUI2:Content Container|Content Container]], with added events and styles relating to button behavior.
  
Clicks on buttons are handled with [[LGUI2:Event Handlers|Event Handlers]] in the same way as clicks on all other elements. See [[LGUI2:Elements#Base Element events|Base Element events]]
+
=== Events ===
 +
{| border="1" style="border-collapse:collapse" cellpadding="5"
 +
!colspan="2"|button events
 +
|-
 +
!colspan="2"|Define these [[LGUI2:Event Handlers|Event Handlers]] within an "eventHandlers" Object
 +
|-
 +
! onPress
 +
| The button is now pressed
 +
|-
 +
! onRelease
 +
| The button is now released
 +
|-
 +
! onPressedChanged
 +
| The Pressed state has been changed
 +
|}
 +
 
 +
=== Styles ===
 +
{| border="1" style="border-collapse:collapse" cellpadding="5"
 +
!colspan="2"|button styles
 +
|-
 +
!colspan="2"|Define these [[LGUI2:Styles|Styles]] within a "styles" Object
 +
|-
 +
! onPress
 +
| The button is now pressed
 +
|-
 +
! onRelease
 +
| The button is now released
 +
|}
  
 
== Examples ==
 
== Examples ==
Line 22: Line 49:
 
   "borderThickness": 1
 
   "borderThickness": 1
 
   "eventHandlers": {
 
   "eventHandlers": {
     "onMouseButtonMove": ["method","MyController","HandleButton1"]
+
     "onRelease": ["method","MyController","HandleButton1"]
 
     }
 
     }
 
   }
 
   }

Latest revision as of 13:53, 11 July 2018

A LavishGUI 2 button element is a standard Content Container element, which can be "Pressed" in various ways (such as a mouse click), usually to activate some behavior.

Defining a button element

A button element is a Content Container, with added events and styles relating to button behavior.

Events

button events
Define these Event Handlers within an "eventHandlers" Object
onPress The button is now pressed
onRelease The button is now released
onPressedChanged The Pressed state has been changed

Styles

button styles
Define these Styles within a "styles" Object
onPress The button is now pressed
onRelease The button is now released

Examples

A button element, with a 1 pixel thick white border around a black background containing a textblock.
When clicked, this button will execute the LavishScript code: MyController:HandleButton1
See lgui2eventargs for an example controller with onMouseButtonMove
{
  "type": "button",
  "name": "button1",
  "content": "My border has some text!",
  "borderBrush": {
    "color": [ 1.0, 1.0, 1.0 ]
  },
  "backgroundBrush": {
    "color": [ 0, 0, 0 ]
  },
  "borderThickness": 1
  "eventHandlers": {
    "onRelease": ["method","MyController","HandleButton1"]
    }
  }
}

LavishGUI 2 Element Types

LavishGUI 2 LavishScript Object Types

Core API (see Using LavishGUI 2 from LavishScript)
lgui2 - lgui2eventargs - lgui2eventhandler - lgui2elementtype - lgui2itemviewgeneratorargs - lgui2inputbinding - lgui2layer - lgui2skin
Enums
elgui2dpad - elgui2edge - elgui2fontflags - elgui2horizontalalignment - elgui2imageorientation - elgui2progresstext - elgui2scrollbar - elgui2verticalignment
Element Components
lgui2brush - lgui2fontstyle - lgui2margins - lgui2item
Element Base Types
lgui2element - lgui2bordered - lgui2contentbase - lgui2headeredcontentbase - lgui2itemlist
Elements