-
-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example of (*InputTextWidget).Callback usage #461
Comments
Sure, I'll add one later today. |
Oh, I cannot add it into this repo cause using imgui.InputTextCallback will add reference of imgui into the go.mod. |
Hmm but the referencje to your imguigo already is present in gomod
That's the problem. I cannot figurę out how to use this callback xd |
@gucio321 Can you explain more detail about the use case you are trying to archive? |
@AllenDang generally, I was trying to solve #460 and wondering, why the following code doesn't work as I expect package main
import (
"fmt"
"github.com/AllenDang/giu"
"github.com/AllenDang/imgui-go"
)
var container string
func loop() {
giu.SingleWindow().Layout(
giu.InputText(&container).Callback(func(i imgui.InputTextCallbackData) int32 {
fmt.Println("input text callback for ", i)
return 1
}),
)
}
func main() {
wnd := giu.NewMasterWindow("issue 461 [Demo]", 640, 480, 0)
wnd.Run(loop)
} what imgui.InputTextCallback is supposed to do exactly? |
@gucio321 Generally speaking, InputTextCallback is used to // Return 0 (pass) if the character is 'i' or 'm' or 'g' or 'u' or 'i'
static int FilterImGuiLetters(ImGuiInputTextCallbackData* data)
{
if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar))
return 0;
return 1;
}
|
yah @AllenDang but my code from previous post isn't caled at any time (I dont recieve log at all) |
hmm @AllenDang I've implemented your code and it doesn't work codepackage main
import (
"strings"
"github.com/AllenDang/giu"
"github.com/AllenDang/imgui-go"
)
var container string
func loop() {
giu.SingleWindow().Layout(
giu.InputText(&container).Callback(func(i imgui.InputTextCallbackData) int32 {
if strings.Contains("imgui", string(i.EventChar())) {
return 0
}
return 1
}),
)
}
func main() {
wnd := giu.NewMasterWindow("issue 461 [Demo]", 640, 480, 0)
wnd.Run(loop)
} what am I doing wrong? |
I can't see any example of using
imgui.InputTextCallback
.is it possible to add one to examples/?
The text was updated successfully, but these errors were encountered: