How to reset internal "state" for inputtextmultiline and maybe other widgets? #886
-
The internal "state" system is causing some headache. It seems the previous text is carried over the next frame. So I gave unqiue IDs. Now suppose the multiline text widget is "destroyed", how do I now reuse the id (or label) for a new multiline text widget as the previous state is still retained? Is there anyway to clear all the previous state of the widget by say their ID...and start a new widget with same ID? This is also useful when i want to clear all the text already present in the text widget. |
Beta Was this translation helpful? Give feedback.
Answered by
gucio321
Oct 25, 2024
Replies: 1 comment
-
Try this: package main
import (
"github.com/AllenDang/giu"
)
var (
currentIdx string = "id1"
data = map[string]*string{
"id1": new(string),
"id2": new(string),
"id3": new(string),
}
)
func loop() {
giu.SingleWindow().Layout(
giu.InputTextMultiline(data[currentIdx]),
giu.RangeBuilder("switcher", []string{"id1", "id2", "id3"}, func(_ int, s string) giu.Widget {
return giu.Button(s).OnClick(func() { currentIdx = s })
}),
)
}
func main() {
wnd := giu.NewMasterWindow("Clean Input Text Multiline [discussion #866]", 640, 480, 0)
wnd.Run(loop)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
gucio321
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this: