Skip to content

Commit 9069b05

Browse files
committed
debugui: add ClosePopup
1 parent 25a433e commit 9069b05

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

control.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,12 @@ func (c *Context) OpenPopup(name string) {
674674
c.bringToFront(cnt)
675675
}
676676

677+
func (c *Context) ClosePopup(name string) {
678+
id := c.idFromGlobalUniqueString(name)
679+
cnt := c.container(id, 0)
680+
cnt.open = false
681+
}
682+
677683
func (c *Context) Popup(name string, f func(layout ContainerLayout)) {
678684
opt := optionPopup | optionAutoSize | optionNoResize | optionNoScroll | optionNoTitle | optionClosed
679685
c.window(name, image.Rectangle{}, opt, f)

example/ui.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ func (g *Game) testWindow(ctx *debugui.Context) {
5454
ctx.Popup("Test Popup", func(layout debugui.ContainerLayout) {
5555
ctx.Button("Hello")
5656
ctx.Button("World")
57+
if ctx.Button("Close") {
58+
ctx.ClosePopup("Test Popup")
59+
}
5760
})
5861
})
5962

0 commit comments

Comments
 (0)