Skip to content

Commit a1359cf

Browse files
committed
example/gallery: add text fields
1 parent fe9b306 commit a1359cf

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

example/gallery/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ type Game struct {
4848
num3_2 float64
4949
num4 float64
5050
num5 int
51+
text1 string
52+
text2 string
5153

5254
selectedOption1, selectedOption2 int
5355
dropdownOptions1, dropdownOptions2 []string
@@ -66,6 +68,8 @@ func NewGame() (*Game, error) {
6668
bg: [3]int{90, 95, 100},
6769
checks: [3]bool{true, false, true},
6870
needResetPosition: true,
71+
text1: "Hello",
72+
text2: "World",
6973
}
7074

7175
return g, nil

example/gallery/ui.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (g *Game) testWindow(ctx *debugui.Context) {
145145
ctx.GridCell(func(bounds image.Rectangle) {
146146
ctx.DrawOnlyWidget(func(screen *ebiten.Image) {
147147
scale := ctx.Scale()
148-
vector.DrawFilledRect(
148+
vector.FillRect(
149149
screen,
150150
float32(bounds.Min.X*scale),
151151
float32(bounds.Min.Y*scale),
@@ -172,6 +172,10 @@ func (g *Game) testWindow(ctx *debugui.Context) {
172172
ctx.SliderF(&g.num4, 0, 10, 0.1, 2)
173173
ctx.Slider(&g.num5, 0, 2, 1)
174174
})
175+
ctx.Header("Text", true, func() {
176+
ctx.TextField(&g.text1)
177+
ctx.TextField(&g.text2)
178+
})
175179
ctx.Header("Licenses", false, func() {
176180
ctx.Text(`The photograph by Chris Nokleberg is licensed under the Creative Commons Attribution 4.0 License
177181

0 commit comments

Comments
 (0)