Skip to content

Commit

Permalink
Add Hint() to InputText.
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenDang committed May 9, 2021
1 parent a1fd3fe commit efb204c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ func (i *ImageWithUrlWidget) Build() {

type InputTextWidget struct {
label string
hint string
value *string
width float32
flags InputTextFlags
Expand All @@ -860,6 +861,7 @@ type InputTextWidget struct {
func InputText(label string, value *string) *InputTextWidget {
return &InputTextWidget{
label: label,
hint: "",
value: value,
width: 0,
flags: 0,
Expand All @@ -868,6 +870,11 @@ func InputText(label string, value *string) *InputTextWidget {
}
}

func (i *InputTextWidget) Hint(hint string) *InputTextWidget {
i.hint = hint
return i
}

func (i *InputTextWidget) Size(width float32) *InputTextWidget {
i.width = width * Context.platform.GetContentScale()
return i
Expand All @@ -893,7 +900,7 @@ func (i *InputTextWidget) Build() {
PushItemWidth(i.width)
}

if imgui.InputTextV(i.label, i.value, int(i.flags), i.cb) && i.onChange != nil {
if imgui.InputTextWithHint(i.label, i.hint, i.value, int(i.flags), i.cb) && i.onChange != nil {
i.onChange()
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/AllenDang/giu
go 1.16

require (
github.com/AllenDang/imgui-go v1.12.1-0.20210421054105-2098c13761b7
github.com/AllenDang/imgui-go v1.12.1-0.20210509113325-c0e4c78e7a88
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3
github.com/go-gl/gl v0.0.0-20210501111010-69f74958bac0 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/AllenDang/imgui-go v1.12.1-0.20210421054105-2098c13761b7 h1:6Bh+kbb8BYlSGsQBM1gbQVZX7lhG249PudT27/7g2oc=
github.com/AllenDang/imgui-go v1.12.1-0.20210421054105-2098c13761b7/go.mod h1:+pYwstqlGGlU2lI1FREPlVAKP2nwV+bNhAlMrbQynhQ=
github.com/AllenDang/imgui-go v1.12.1-0.20210509113325-c0e4c78e7a88 h1:dXpshnNwPl+QjFOiJNFlQrtOz1oA565EO9FUseKvlhU=
github.com/AllenDang/imgui-go v1.12.1-0.20210509113325-c0e4c78e7a88/go.mod h1:+pYwstqlGGlU2lI1FREPlVAKP2nwV+bNhAlMrbQynhQ=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 h1:baVdMKlASEHrj19iqjARrPbaRisD7EuZEVJj6ZMLl1Q=
Expand Down

0 comments on commit efb204c

Please sign in to comment.