# Button

Inheritance Button View Module hilo/view/Button Requires hilo/core/Hilo, hilo/core/Class, hilo/view/View, hilo/view/Drawable, hilo/util/util Source Button.js
Button class is a simple button class, contains four kinds of state: 'up', 'over', 'down', 'disabled'
demo:

    var btn = new Hilo.Button({
        image: buttonImage,
        upState: {rect:[0, 0, 64, 64]},
        overState: {rect:[64, 0, 64, 64]},
        downState: {rect:[128, 0, 64, 64]},
        disabledState: {rect:[192, 0, 64, 64]}
    });

### Properties

Show Inherited Properties

| Property | Defined
--- | --- | ---
| disabledState:Object The property of button 'disabled' state or collections of its drawable properties. | Button
| downState:Object The property of button 'down' state or collections of its drawable properties. | Button
| enabled:Boolean Is button enabled. | Button
| overState:Object The property of button 'over' state or collections of its drawable properties. | Button
| state:String the state name of button, could be one of Button.UP|OVER|DOWN|DISABLED, readonly! | Button
| upState:Object The property of button 'up' state or collections of its drawable properties. | Button
| useHandCursor:Boolean If true, cursor over the button will become a pointer cursor, default value is true. | Button
| OVER:String static Statics value of Button's 'over' state. | Button
| DOWN:String static Statics value of Button's 'down' state. | Button
| DISABLED:String static Statics value of Button's 'disabled' state. | Button
| UP:String static Statics value of Button's 'up' state. | Button
| align:String|Function The alignment of the view, the value must be one of Hilo.align enum. | View
| alpha:Number The opacity of the view, default value is 1. | View
| background:Object The background style to fill the view, can be css color, gradient or pattern of canvas | View
| boundsArea:Array The vertex points of the view, the points are relative to the center point. | View
| depth:Number The z index of the view, readonly! | View
| drawable:Drawable The drawable object of the view. | View
| height:Number The height of the view, default value is 0. | View
| id:String The identifier for the view. | View
| mask:Graphics Sets a mask for the view. | View
| onUpdate:Function This method will call while the view need update(usually caused by ticker update). | View
| parent:Container The parent view of this view, readonly! | View
| pivotX:Number Position of the center point on the x axis of the view, default value is 0. | View
| pivotY:Number Position of the center point on the y axis of the view, default value is 0. | View
| pointerEnabled:Boolean Is the view can receive DOM events, default value is true. | View
| rotation:Number The rotation of the view in angles, default value is 0. | View
| scaleX:Number The x axis scale factor of the view, default value is 1. | View
| scaleY:Number The y axis scale factor of the view, default value is 1. | View
| tint:Number The tint applied to the view，default is 0xFFFFFF.Only support in WebGL mode. | View
| transform:Matrix The transform of the view.If set the transform, x, y, scaleX, scaleY, rotation, pivotX, pivotY will be ignored.default is null. | View
| visible:Boolean The visibility of the view. | View
| width:Number The width of the view, default value is 0. | View
| x:Number The position of the view on the x axis relative to the local coordinates of the parent, default value is 0. | View
| y:Number The position of the view on the y axis relative to the local coordinates of the parent, default value is 0. | View

### Methods

Show Inherited Methods

| Method | Defined
--- | --- | ---
| Button(properties:Object) Constructor | Button
| setEnabled(enabled:Boolean):Button Set whether the button is enabled. | Button
| setState(state:String):Button Set the state of the button. | Button
| addTo(container:Container, index:Uint):View Add current view to a Contaner. | View
| fire(type:String, detail:Object):Boolean Send events. | View
| getBounds():Array Get the bounds of the view as a circumscribed rectangle and all vertex points relative to the coordinates of the stage. | View
| getScaledHeight():Number Get the scaled height of the view. | View
| getScaledWidth():Number Get the scaled width of the view. | View
| getStage():Stage Get the stage object of the view. | View
| hitTestObject(object:View, usePolyCollision:Boolean) Determining whether an object is in the circumscribed rectangle of current view. | View
| hitTestPoint(x:Number, y:Number, usePolyCollision:Boolean):Boolean Determining whether a point is in the circumscribed rectangle of current view. | View
| off(type:String, listener:Function):Object Remove one event listener. | View
| on(type:String, listener:Function, once:Boolean):Object Add an event listenser. | View
| removeFromParent():View Remove current view from it's parent container | View
| render(renderer:Renderer, delta:Number) The render method of current view. | View
| toString():String Get a string representing current view. | View

### Property Detail

[Static] DISABLED:String
Statics value of Button's 'disabled' state.
disabledState:Object
The property of button 'disabled' state or collections of its drawable properties.
[Static] DOWN:String
Statics value of Button's 'down' state.
downState:Object
The property of button 'down' state or collections of its drawable properties.
enabled:Boolean
Is button enabled. default value is true, readonly!
[Static] OVER:String
Statics value of Button's 'over' state.
overState:Object
The property of button 'over' state or collections of its drawable properties.
state:String
the state name of button, could be one of Button.UP|OVER|DOWN|DISABLED, readonly!
[Static] UP:String
Statics value of Button's 'up' state.
upState:Object
The property of button 'up' state or collections of its drawable properties.
useHandCursor:Boolean
If true, cursor over the button will become a pointer cursor, default value is true.

### Constructor

Button(properties:Object)

parameters
properties:Object — create object properties. Contains all writable properties. Also contains:

- image - the image element that button image is in

### Method Detail

setEnabled(enabled:Boolean):Button
Set whether the button is enabled.

parameters
enabled:Boolean — Show whether the button is enabled.

return
  Button — Return the button itself.

setState(state:String):Button
Set the state of the button. Invoke inside the Button and may not be used.

parameters
state:String — New state of the button.

return
  Button — Return the button itself.