Skip to content

Commit dd8eede

Browse files
committed
example: do not send a buffer when empty
1 parent 3f188ae commit dd8eede

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

example/ui.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,19 @@ func (g *Game) logWindow(ctx *debugui.Context) {
150150
}
151151
})
152152
ctx.GridCell(func() {
153-
var submitted bool
153+
var submit bool
154154
ctx.SetGridLayout([]int{-1, 70}, nil)
155155
if ctx.TextField(&g.logSubmitBuf) {
156-
if ebiten.IsKeyPressed(ebiten.KeyEnter) {
157-
submitted = true
156+
if g.logSubmitBuf != "" && ebiten.IsKeyPressed(ebiten.KeyEnter) {
157+
submit = true
158158
}
159159
}
160160
if ctx.Button("Submit") {
161-
submitted = true
161+
if g.logSubmitBuf != "" {
162+
submit = true
163+
}
162164
}
163-
if submitted {
165+
if submit {
164166
g.writeLog(g.logSubmitBuf)
165167
g.logSubmitBuf = ""
166168
ctx.SetTextFieldValue(&g.logSubmitBuf)

0 commit comments

Comments
 (0)