package Ġcom . ac orn ui . core . input . interaction Ċ Ċ import Ġcom . ac orn ui . component . Ui Component Ro Ċ import Ġcom . ac orn ui . component . stage Ċ import Ġcom . ac orn ui . core . Disposable Ċ import Ġcom . ac orn ui . core . input .* Ċ import Ġcom . ac orn ui . core . userInfo Ċ import Ġcom . ac orn ui . signal . Signal 0 Ċ Ċ /** Ċ Ġ* ĠProvides Ġinformation Ġto Ġbuttons Ġabout Ġthe Ġstate Ġof Ġmouse Ġand Ġtouch . Ċ Ġ* Ġ@ param Ġhost ĠThe Ġtarget Ġto Ġwatch . Ċ Ġ*/ Ċ class ĠMouse Or Touch State ( private Ġval Ġhost : ĠUi Component Ro ) Ġ: ĠDis posable Ġ{ ĊĊ ĉ private Ġval Ġstage Ġ= Ġhost . stage ĊĊ ĉ private Ġval Ġ_ is Over Changed Ġ= ĠSignal 0 () ĊĊ ĉ /** Ċĉ Ġ* ĠDis patched Ġwhen Ġ[ is Over ] Ġhas Ġchanged . Ċĉ Ġ*/ Ċ ĉ val Ġis Over Changed Ġ= Ġ_ is Over Changed . as Ro () ĊĊ ĉ private Ġval Ġ_ is Down Changed Ġ= ĠSignal 0 () ĊĊ ĉ /** Ċĉ Ġ* ĠDis patched Ġwhen Ġ[ is Down ] Ġhas Ġchanged . Ċĉ Ġ*/ Ċ ĉ val Ġis Down Changed Ġ= Ġ_ is Down Changed . as Ro () ĊĊ ĉ /** Ċĉ Ġ* ĠTrue Ġif Ġeither Ġthe Ġtouch Ġor Ġmouse Ġis Ġover Ġthe Ġ[ host ]. Ċĉ Ġ*/ Ċ ĉ var Ġis Over : ĠBoolean Ġ= Ġfalse Ċĉ ĉ private Ġset ( value ) Ġ{ Ċĉĉ ĉ if Ġ( value Ġ== Ġfield ) Ġreturn Ċĉĉ ĉ field Ġ= Ġvalue Ċĉĉ ĉ _ is Over Changed . dispatch () Ċĉ ĉ } ĊĊ ĉ /** Ċĉ Ġ* ĠIf Ġthe Ġmouse Ġor Ġtouch Ġis Ġpressed Ġon Ġthe Ġtarget , Ġis Down Ġbecomes Ġtrue , Ġand Ġwhen Ġthe Ġmouse Ġor Ġtouch Ġis Ġreleased Ċĉ Ġ* Ġ( pot entially Ġoutside Ġof Ġthe Ġtarget ), Ġis Down Ġbecomes Ġfalse . Ċĉ Ġ*/ Ċ ĉ var Ġis Down : ĠBoolean Ġ= Ġfalse Ċĉ ĉ private Ġset ( value ) Ġ{ Ċĉĉ ĉ if Ġ( value Ġ== Ġfield ) Ġreturn Ċĉĉ ĉ field Ġ= Ġvalue Ċĉĉ ĉ _ is Down Changed . dispatch () Ċĉ ĉ } ĊĊ ĉ private Ġval Ġroll Over Handler Ġ= Ġ{ Ġevent : ĠMouse Interaction Ro Ġ-> Ċĉ ĉ is Over Ġ= Ġtrue Ċ ĉ } ĊĊ ĉ private Ġval Ġroll Out Handler Ġ= Ġ{ Ġevent : ĠMouse Interaction Ro Ġ-> Ċĉ ĉ is Over Ġ= Ġfalse Ċ ĉ } ĊĊ ĉ private Ġval Ġmouse Down Handler Ġ= Ġ{ Ġevent : ĠMouse Interaction Ro Ġ-> Ċĉ ĉ if Ġ(! is Down Ġ&& Ġevent . button Ġ== ĠWhich Button . LEFT ) Ġ{ Ċĉĉ ĉ is Down Ġ= Ġtrue Ċĉĉ ĉ stage . mouse Up (). add ( stage Mouse Up Handler , Ġtrue ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġval Ġtouch Start Handler Ġ= Ġ{ Ġevent : ĠTouch Interaction Ro Ġ-> Ċĉ ĉ if Ġ(! is Down ) Ġ{ Ċĉĉ ĉ is Down Ġ= Ġtrue Ċĉĉ ĉ stage . touch End (). add ( stage Touch End Handler , Ġtrue ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġval Ġstage Mouse Up Handler Ġ= Ġ{ Ġevent : ĠMouse Interaction Ro Ġ-> Ċĉ ĉ if Ġ( event . button Ġ== ĠWhich Button . LEFT ) Ġ{ Ċĉĉ ĉ is Down Ġ= Ġfalse Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġval Ġstage Touch End Handler Ġ= Ġ{ Ġevent : ĠTouch Interaction Ro Ġ-> Ċĉ ĉ is Down Ġ= Ġfalse Ċ ĉ } ĊĊ ĉ override Ġfun Ġdispose () Ġ{ Ċĉ ĉ host . roll Over (). remove ( roll Over Handler ) Ċĉ ĉ host . roll Out (). remove ( roll Out Handler ) Ċĉ ĉ host . mouse Down (). remove ( mouse Down Handler ) Ċĉ ĉ host . touch Start (). remove ( touch Start Handler ) Ċĉ ĉ stage . mouse Up (). remove ( stage Mouse Up Handler ) Ċĉ ĉ stage . touch End (). remove ( stage Touch End Handler ) Ċĉ ĉ _ is Over Changed . dispose () Ċ ĉ } ĊĊ ĉ init Ġ{ Ċĉ ĉ // ĠMouse Ġover Ġ/ Ġout Ġhandlers Ġcause Ġproblems Ġon Ġmobile . Ċĉ ĉ if Ġ(! userInfo . is Touch Device ) Ġ{ Ċĉĉ ĉ host . roll Over (). add ( roll Over Handler ) Ċĉĉ ĉ host . roll Out (). add ( roll Out Handler ) Ċĉ ĉ } Ċĉ ĉ host . mouse Down (). add ( mouse Down Handler ) Ċĉ ĉ host . touch Start (). add ( touch Start Handler ) Ċ ĉ } Ċ }