File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -332,3 +332,15 @@ func (c *container) toggle(id WidgetID) {
332332 }
333333 c .toggledIDs [id ] = struct {}{}
334334}
335+
336+ func (c * Context ) bringToFront (cnt * container ) {
337+ c .lastZIndex ++
338+ cnt .zIndex = c .lastZIndex
339+ }
340+
341+ func (c * Context ) addUsedContainer (id WidgetID ) {
342+ if c .usedContainers == nil {
343+ c .usedContainers = map [WidgetID ]struct {}{}
344+ }
345+ c .usedContainers [id ] = struct {}{}
346+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ import (
1212 "github.com/hajimehoshi/ebiten/v2"
1313)
1414
15+ func clamp [T int | float64 ](x , a , b T ) T {
16+ return min (b , max (a , x ))
17+ }
18+
1519type Context struct {
1620 pointing pointing
1721
@@ -44,6 +48,13 @@ type Context struct {
4448 err error
4549}
4650
51+ func (c * Context ) wrapError (f func () error ) {
52+ if c .err != nil {
53+ return
54+ }
55+ c .err = f ()
56+ }
57+
4758func (c * Context ) update (f func (ctx * Context ) error ) (err error ) {
4859 if c .err != nil {
4960 return c .err
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -176,3 +176,8 @@ func (c *Context) isCapturingInput() bool {
176176func (c * Context ) CurrentWidgetID () WidgetID {
177177 return c .currentID
178178}
179+
180+ func (c * Context ) setFocus (id WidgetID ) {
181+ c .focus = id
182+ c .keepFocus = true
183+ }
You can’t perform that action at this time.
0 commit comments