Make value getters/setters more consistent

See #6
This commit is contained in:
2024-06-27 14:01:14 -04:00
parent d0ee6c432c
commit 638fc61d83
11 changed files with 128 additions and 105 deletions

View File

@@ -11,8 +11,8 @@ type TextInput struct {
tomo.TextBox
text []rune
on struct {
enter event.FuncBroadcaster
edit event.FuncBroadcaster
enter event.FuncBroadcaster
valueChange event.FuncBroadcaster
}
}
@@ -47,9 +47,10 @@ 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)
// OnValueChange specifies a function to be called when the user edits the input
// text.
func (this *TextInput) OnValueChange (callback func ()) event.Cookie {
return this.on.valueChange.Connect(callback)
}
func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
@@ -100,7 +101,7 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
this.Select(dot)
if changed {
this.SetText(string(this.text))
this.on.edit.Broadcast()
this.on.valueChange.Broadcast()
}
}