import FI_Node from '../../fiengine/node/FI_Node'
import FI_Text from '../../fiengine/component/FI_Text'
import FI_Touchable from '../../fiengine/component/FI_Touchable'

export default class Button extends FI_Node{
  constructor(textContent){
    super()
    this.textContent = textContent
  }
  onAdded(){
    var textNode = this.addChild(new FI_Node())

    var textComponent = textNode.addComponent(new FI_Text())
    textComponent.content = this.textContent
    textComponent.onSizeChange = (t)=>{
      this.size.width = t.size.width
    }

    var touchableComponent = this.addComponent(new FI_Touchable())
    touchableComponent.onMouseIn = (t)=>{
      t.node.scale.x = 1.1
      t.node.scale.y = 1.1
    }
    touchableComponent.onMouseOut = (t)=>{
      t.node.scale.x = 1.0
      t.node.scale.y = 1.0
    }
    touchableComponent.onMouseDown = (t)=>{
      t.node.scale.x = 1.0
      t.node.scale.y = 1.0
    }
    touchableComponent.onMouseUp = (t)=>{
      t.node.scale.x = 1.1
      t.node.scale.y = 1.1
    }
  }
}

@@ -163,16 +163,75 @@
 chable'%0A
+import %7B FI_ScaleTo %7D from '../../fiengine/action/FI_Scale'
 %0Aexport 
@@ -360,16 +360,61 @@
 dded()%7B%0A
+    var inner = this.addChild(new FI_Node())%0A
     var 
@@ -424,20 +424,21 @@
 tNode = 
-this
+inner
 .addChil
@@ -764,364 +764,466 @@
     
-t.node.scale.x = 1.1%0A      t.node.scale.y = 1.1%0A    %7D%0A    touchableComponent.onMouseOut = (t)=%3E%7B%0A      t.node.scale.x = 1.0%0A      t.node.scale.y = 1.0%0A    %7D%0A    touchableComponent.onMouseDown = (t)=%3E%7B%0A      t.node.scale.x = 1.0%0A      t.node.scale.y = 1.0%0A    %7D%0A    touchableComponent.onMouseUp = (t)=%3E%7B%0A      t.node.scale.x = 1.1%0A      t.node.scale.y = 1.1
+inner.removeAllActions()%0A      inner.addAction(new FI_ScaleTo(1.1,1.1,250))%0A    %7D%0A    touchableComponent.onMouseOut = (t)=%3E%7B%0A      inner.removeAllActions()%0A      inner.addAction(new FI_ScaleTo(1,1,250))%0A    %7D%0A    touchableComponent.onMouseDown = (t)=%3E%7B%0A      inner.removeAllActions()%0A      inner.addAction(new FI_ScaleTo(1,1,75))%0A    %7D%0A    touchableComponent.onMouseUp = (t)=%3E%7B%0A      inner.removeAllActions()%0A      inner.addAction(new FI_ScaleTo(1.1,1.1,75))
 %0A   

use action 'ScaleTo'