File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -65,9 +65,9 @@ func (c *Context) wrapError(f func() error) {
6565 c .err = f ()
6666}
6767
68- func (c * Context ) update (f func (ctx * Context ) error ) (err error ) {
68+ func (c * Context ) update (f func (ctx * Context ) error ) (captured bool , err error ) {
6969 if c .err != nil {
70- return c .err
70+ return false , c .err
7171 }
7272
7373 c .pointing .update ()
@@ -80,12 +80,12 @@ func (c *Context) update(f func(ctx *Context) error) (err error) {
8080 }()
8181
8282 if err := f (c ); err != nil {
83- return err
83+ return false , err
8484 }
8585 if c .err != nil {
86- return c .err
86+ return false , c .err
8787 }
88- return nil
88+ return c . isCapturingInput (), nil
8989}
9090
9191func (c * Context ) beginUpdate () {
Original file line number Diff line number Diff line change @@ -14,9 +14,16 @@ type DebugUI struct {
1414
1515// Update updates the debug UI.
1616//
17+ // Update returns true if the debug UI is capturing input, e.g. when a widget has focus.
18+ // Otherwise, Update returns false.
19+ //
1720// Update should be called once in the game's Update function.
18- func (d * DebugUI ) Update (f func (ctx * Context ) error ) error {
19- return d .ctx .update (f )
21+ func (d * DebugUI ) Update (f func (ctx * Context ) error ) (bool , error ) {
22+ captured , err := d .ctx .update (f )
23+ if err != nil {
24+ return false , err
25+ }
26+ return captured , nil
2027}
2128
2229// Draw draws the debug UI.
@@ -26,8 +33,3 @@ func (d *DebugUI) Draw(screen *ebiten.Image) {
2633 d .ctx .draw (screen )
2734 d .ctx .screenWidth , d .ctx .screenHeight = screen .Bounds ().Dx (), screen .Bounds ().Dy ()
2835}
29-
30- // IsCapturingInput reports whether the debug UI is capturing input, e.g. when a widget has focus.
31- func (d * DebugUI ) IsCapturingInput () bool {
32- return d .ctx .isCapturingInput ()
33- }
You can’t perform that action at this time.
0 commit comments