import { IDisplayObjectContainerWrapper , ITextWrapper , EngineAdapter , DisplayObjectWrapperMouseEvent } from "fgraphics/dist/index" ; import { BaseEventListenerObject } from "fcore/dist/index" ; import { FC } from "../FC" ; import { ITooltipData } from "../../tooltip/ITooltipData" ; export class BaseConsoleButton extends BaseEventListenerObject { public view : IDisplayObjectContainerWrapper ; public field : ITextWrapper ; private _label : string = "" ; public tooltipData : ITooltipData ; constructor ( ) { super ( ) ; } protected construction ( ) { super . construction ( ) ; this . view = EngineAdapter . instance . createDisplayObjectContainerWrapper ( ) ; this . view . interactive = true ; this . view . buttonMode = true ; this . field = EngineAdapter . instance . createTextWrapper ( ) ; this . view . addChild ( this . field ) ; this . field . color = FC . config . btnSettings . labelColor ; this . field . size = FC . config . btnSettings . labelSize ; this . commitData ( ) ; this . onOut ( ) ; } protected addListeners ( ) { super . addListeners ( ) ; this . eventListenerHelper . addEventListener ( this . view , DisplayObjectWrapperMouseEvent . ROLL_OVER , this . onOver ) ; this . eventListenerHelper . addEventListener ( this . view , DisplayObjectWrapperMouseEvent . ROLL_OUT , this . onOut ) ; this . eventListenerHelper . addEventListener ( this . view , DisplayObjectWrapperMouseEvent . CLICK , this . onClick ) ; this . eventListenerHelper . addEventListener ( this . view , DisplayObjectWrapperMouseEvent . MOUSE_UP_OUTSIDE , this . onOut ) ; } private onOver ( ) { this . view . alpha = 1 ; if ( this . tooltipData ) { FC . tooltipManager . show ( this . tooltipData ) ; } } private onOut ( ) { this . view . alpha = 0.75 ; FC . tooltipManager . hide ( ) ; } protected onClick ( ) { this . onOut ( ) ; } protected commitData ( ) { super . commitData ( ) ; this . field . text = this . label ; this . arrange ( ) ; } protected arrange ( ) { super . arrange ( ) ; } get label ( ) : string { return this . _label ; } set label ( value ) { if ( value == this . label ) { return ; } this . _label = value ; this . commitData ( ) ; } }