-
-
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
[Feature Request] Command-line demo #660
Comments
Generally i can't understand what is the problem... |
@gucio321 Thanks. I am not sure this will work, but I'll try. Moreover, I can't understand why this code from here won't run. - https://github.com/AllenDang/giu/blob/master/examples/issue-501/main.go I received these errors:
First two Can you please suggest me any solution? |
@enty8080 I can't reproduce your error 😢 On In case of your issue: My code
package main
import (
"github.com/AllenDang/giu"
"github.com/AllenDang/imgui-go"
)
var c string
func loop() {
imgui.PushStyleVarVec2(imgui.StyleVarWindowPadding, imgui.Vec2{0, 0})
imgui.PushStyleVarFloat(imgui.StyleVarFrameRounding, 0)
defer imgui.PopStyleVarV(2)
giu.SingleWindow().Layout(
giu.InputTextMultiline(&c).Size(-1, -1),
)
}
func main() {
wnd := giu.NewMasterWindow("Issue 660 [demo]", 640, 80, 0)
wnd.Run(loop)
} |
@gucio321 Yeah, and I want to |
@enty8080 so e.g. like this package main
import (
"fmt"
"github.com/AllenDang/giu"
"github.com/AllenDang/imgui-go"
)
var c string
func loop() {
imgui.PushStyleVarVec2(imgui.StyleVarWindowPadding, imgui.Vec2{0, 0})
imgui.PushStyleVarFloat(imgui.StyleVarFrameRounding, 0)
defer imgui.PopStyleVarV(2)
giu.SingleWindow().RegisterKeyboardShortcuts(giu.WindowShortcut{
Key: giu.KeyEnter,
Callback: func() {
fmt.Println(c)
c = ""
},
}).Layout(
giu.InputTextMultiline(&c).Size(-1, -1),
)
}
func main() {
wnd := giu.NewMasterWindow("Issue 660 [demo]", 640, 80, 0)
wnd.Run(loop)
} |
@gucio321 Thank you very much! May I ask, where did you master P.S. I made a mistake, it should not print text, it should display it on the screen right below the input. Also, idk why, but |
I just was using these libraries for a longer time (especially giu, because I'm not really familiar with imgui-go)
meh it is so tricky... I think you need to play with InputTextCallback. package main
import (
"github.com/AllenDang/giu"
"github.com/AllenDang/imgui-go"
)
var (
c string
cmd string
isEnterPressed bool
)
func loop() {
imgui.PushStyleVarVec2(imgui.StyleVarWindowPadding, imgui.Vec2{0, 0})
imgui.PushStyleVarFloat(imgui.StyleVarFrameRounding, 0)
defer imgui.PopStyleVarV(2)
giu.SingleWindow().Layout(
giu.Label(cmd),
giu.InputTextMultiline(&c).Size(-1, -1).Callback(func(d imgui.InputTextCallbackData) int32 {
if isEnterPressed {
cmd += "\n" + c
d.DeleteBytes(0, len(d.Buffer()))
isEnterPressed = false
}
// in this particular case, we ar not able to edit buffer (WHY?)
if d.EventFlag() == imgui.InputTextFlagsCallbackCharFilter {
if rune(d.EventChar()) == '\n' {
isEnterPressed = true
} else {
isEnterPressed = false
}
}
return 0
}).Flags(giu.InputTextFlagsCallbackAlways|giu.InputTextFlagsCallbackCharFilter),
)
}
func main() {
wnd := giu.NewMasterWindow("Issue 660 [demo]", 640, 80, 0)
wnd.Run(loop)
} also ref: #434 (thats not the same but it shows how to use input text callbacks) |
@gucio321 Thanks |
Related problem
No response
Your request
Hey.
That's me again. I am just wondering if it is possible to write a command line using giu. It should wait for user's input in loop and do something when user hits enter.
The main problem is that
giu.InputText()
appears with a border around the input, but I want a command-line to be a just a prompt, not an input box. Like in a regular terminal emulator or evencmd.exe
.Please, if you have any ideas on how to do this, suggest them.
Thanks in advance.
Alternative solution
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: