import { CheckBox } from "./CheckBox" ; import { RadioGroup } from "./RadioGroup" ; import { Texture } from "pixi.js" ; export class Radio extends CheckBox { private _group ! : RadioGroup ; public _groupIndex : number = - 1 ; constructor ( options ? ) { super ( options ) ; } /**
     * 设置 RadioGroup
     */ set group ( group ) { if ( this . _group && this . _group != group ) { throw new Error ( "当前单选按钮已经存在RadioGroup" ) ; } this . _group = group ; this . _groupIndex = group . put ( this ) ; } get group ( ) : RadioGroup { return this . _group ; } /**
     * 是否选中
     */ set selected ( selected ) { if ( this . group ) { this . group . select = this . _groupIndex ; } else { this . setSelectedDraw ( selected ) ; } this . emit ( "selected" , selected ) ; } get selected ( ) : boolean { return this . _selected ; } param selected setSelectedDraw ( selected ) { if ( this . _selected == selected ) { return ; } this . _selected = selected ; this . currState = selected ? Radio . STATE . SELECT : Radio . STATE . NORMAL ; this . draw ( ) ; if ( this . _chageCallback ) { this . _chageCallback ( selected ) ; } } param options destroy ( options ? ) { if ( this . _group ) { this . _group . remove ( this ) ; } super . destroy ( options ) ; } }