Add OnEdit to TextInput
This commit is contained in:
parent
4d790f7264
commit
ca2f9654b3
11
input.go
11
input.go
@ -13,6 +13,7 @@ type TextInput struct {
|
||||
text []rune
|
||||
on struct {
|
||||
enter event.FuncBroadcaster
|
||||
edit event.FuncBroadcaster
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +48,11 @@ func (this *TextInput) OnEnter (callback func ()) event.Cookie {
|
||||
return this.on.enter.Connect(callback)
|
||||
}
|
||||
|
||||
// OnEdit specifies a function to be called when the user edits the input text.
|
||||
func (this *TextInput) OnEdit (callback func ()) event.Cookie {
|
||||
return this.on.edit.Connect(callback)
|
||||
}
|
||||
|
||||
func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
|
||||
dot := this.Dot()
|
||||
modifiers := this.Modifiers()
|
||||
@ -93,7 +99,10 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
|
||||
}
|
||||
|
||||
this.Select(dot)
|
||||
if changed { this.SetText(string(this.text)) }
|
||||
if changed {
|
||||
this.SetText(string(this.text))
|
||||
this.on.edit.Broadcast()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *TextInput) handleScroll (x, y float64) {
|
||||
|
Loading…
Reference in New Issue
Block a user