example of (*InputTextWidget).Callback usage
I can't see any example of using imgui.InputTextCallback.
is it possible to add one to examples/?
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. The usage should be very straight forward, define a callback function and pass it to InputText(..).Callback() and check the document of imgui.
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
The usage should be very straight forward, define a callback function and pass it to InputText(..).Callback() and check the document of imgui..
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 filter the input string. Here is the reference from C++.
// 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
code
package 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?
Need to specify (one or more of) InputTextFlagsCallback* flags (see #660 #460 #434)