Change Label Text later #843
Answered
by
OfflinePing
OfflinePing
asked this question in
Q&A
Replies: 2 comments
-
|
You can't "change labels text after using them" due to imgui mechanism. You can change it in the next frame so you need some variable. Could you show code pls |
Beta Was this translation helpful? Give feedback.
0 replies
-
package main
var (
Error = ""
)
func loop() {
Register := g.Window("Register").Size(270, 280).Flags(g.WindowFlagsNoCollapse | g.WindowFlagsNoResize | g.WindowFlagsNoTitleBar)
Register.Layout(
g.Align(g.AlignCenter).To(
g.Label("Register").Font(Utils.MonoFont),
Space,
Space,
Space,
Space,
g.Row(
g.Label("Email: "),
g.InputText(&Utils.RegUser.Email).Hint("[email protected]"),
),
g.Row(
g.Label("Username:"),
g.InputText(&Utils.RegUser.Username).Hint("Claas.sh"),
),
g.Row(
g.Label("Password: "),
g.InputText(&Utils.RegUser.Password).Flags(g.InputTextFlagsPassword).Hint("*******"),
),
g.Row(
g.Label("Confirm: "),
g.InputText(&Utils.RegUser.PasswordConfirm).Flags(g.InputTextFlagsPassword).Hint("*******"),
),
Space,
Space,
g.Row(
//TODO: Add error message
g.Popup("Error").Layout(
g.Style().SetDisabled(true).To(
g.Labelf("Error: %s", Error),
),
g.Button("Close").OnClick(func() {
g.CloseCurrentPopup()
}),
),
g.Button("Register").OnClick(func() {
Reg := AuthSystem.Register(Utils.RegUser)
if Reg == AuthSystem.Registered {
Utils.CurrentPage = "Login"
return
} else {
Error = Reg
g.OpenPopup("Error")
}
}),
),
),
)
}
// TODO: CSS Styling
func main() {
wnd := g.NewMasterWindow("Cloud - Universal", 1, 1, g.MasterWindowFlagsNotResizable|g.MasterWindowFlagsTransparent|g.MasterWindowFlagsFrameless)
wnd.SetTargetFPS(200)
//Utils.MonoFont = g.Context.FontAtlas.AddFont("Fonts/Mono.ttf", 25)
//g.Context.FontAtlas.SetDefaultFont("Fonts/Kanit-Light.ttf", 22)
if err := g.ParseCSSStyleSheet(cssStyle); err != nil {
panic(err)
}
go func() {
for range time.Tick(time.Millisecond) {
g.Update()
}
}()
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
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to change the Text of a Label after using it in layout? I tried using Variables but that won't seem to work properly because some Glyph error
Beta Was this translation helpful? Give feedback.
All reactions