author suo
  module tool { export class ToggleButton extends Button { private _selected : boolean = false ; private _cancelHanlder : Handler ; private _selectHandler : Handler ; public constructor ( root , soundName = null , canExpand = false , isOffset = false ) { super ( root , soundName , canExpand , isOffset ) ; } /**
         * 鼠标点击函数（重写！）
         */ protected onMouseClick ( e ) { if ( this . _mouseClickHandler != null ) { this . _mouseClickHandler . runWith ( this ) ; } } /**
         * 设置是否选中
         */ public set selected ( value ) { this . _selected = value ; if ( this . _selected ) { if ( this . _selectHandler != null ) { this . _selectHandler . runWith ( this ) ; } } else { if ( this . _cancelHanlder ) { this . _cancelHanlder . runWith ( this ) ; } } } /**
         * 设置取消函数
         */ public set cancelHanlder ( value ) { this . _cancelHanlder = value ; } /**
         * 设置选中函数函数
         */ public set selectHandler ( value ) { this . _selectHandler = value ; } /**
         * 获得是否选中
         */ public get selected ( ) : boolean { return this . _selected ; } /**
         * 释放
         */ public dispose ( ) { if ( this . _cancelHanlder ) { this . _cancelHanlder . recover ( ) ; this . _cancelHanlder = null ; } if ( this . _selectHandler ) { this . _selectHandler . recover ( ) ; this . _selectHandler = null ; } super . dispose ( ) ; } } }