@@ -9,13 +9,16 @@ import (
99 "math"
1010 "os"
1111 "strconv"
12+ "strings"
1213 "unicode/utf8"
1314
1415 "github.com/hajimehoshi/ebiten/v2"
1516 "github.com/hajimehoshi/ebiten/v2/exp/textinput"
1617 "github.com/hajimehoshi/ebiten/v2/inpututil"
1718)
1819
20+ const idSeparator = "\x00 "
21+
1922const (
2023 realFmt = "%.3g"
2124 sliderFmt = "%.2f"
@@ -152,7 +155,8 @@ func (c *Context) Label(text string) {
152155 })
153156}
154157
155- func (c * Context ) button (label string , idStr string , opt option ) (controlID , bool ) {
158+ func (c * Context ) button (label string , opt option ) (controlID , bool ) {
159+ label , idStr , _ := strings .Cut (label , idSeparator )
156160 id := c .idFromString (idStr )
157161 return id , c .control (id , opt , func (bounds image.Rectangle ) Response {
158162 var res Response
@@ -372,7 +376,8 @@ func (c *Context) number(value *float64, step float64, digits int, opt option) b
372376 }) != 0
373377}
374378
375- func (c * Context ) header (label string , idStr string , istreenode bool , opt option , f func ()) {
379+ func (c * Context ) header (label string , istreenode bool , opt option , f func ()) {
380+ label , idStr , _ := strings .Cut (label , idSeparator )
376381 id := c .idFromString (idStr )
377382 _ , toggled := c .toggledIDs [id ]
378383 c .SetGridLayout ([]int {- 1 }, nil )
@@ -427,8 +432,8 @@ func (c *Context) header(label string, idStr string, istreenode bool, opt option
427432 }
428433}
429434
430- func (c * Context ) treeNode (label string , idStr string , opt option , f func ()) {
431- c .header (label , idStr , true , opt , func () {
435+ func (c * Context ) treeNode (label string , opt option , f func ()) {
436+ c .header (label , true , opt , func () {
432437 c .layout ().indent += c .style .indent
433438 defer func () {
434439 c .layout ().indent -= c .style .indent
0 commit comments