diff --git a/input.go b/input.go index 0c60f9e..dd0a5f9 100644 --- a/input.go +++ b/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) {