Change OnEnter to OnConfirm

Full remediation of #6
This commit is contained in:
2024-06-27 14:09:58 -04:00
parent 638fc61d83
commit 1125d98b3d
5 changed files with 32 additions and 32 deletions

View File

@@ -15,8 +15,8 @@ type NumberInput struct {
increment *Button
decrement *Button
on struct {
enter event.FuncBroadcaster
valueChange event.FuncBroadcaster
confirm event.FuncBroadcaster
}
}
@@ -43,7 +43,7 @@ func NewNumberInput (value float64) *NumberInput {
box.OnScroll(box.handleScroll)
box.OnKeyDown(box.handleKeyDown)
box.input.OnEnter(box.handleEnter)
box.input.OnConfirm(box.handleConfirm)
box.input.OnValueChange(box.on.valueChange.Broadcast)
box.increment.OnClick(func () { box.shift(1) })
box.decrement.OnClick(func () { box.shift(-1) })
@@ -67,10 +67,10 @@ func (this *NumberInput) OnValueChange (callback func ()) event.Cookie {
return this.on.valueChange.Connect(callback)
}
// OnEnter specifies a function to be called when the user presses enter within
// the text input.
func (this *NumberInput) OnEnter (callback func ()) event.Cookie {
return this.on.enter.Connect(callback)
// OnConfirm specifies a function to be called when the user presses enter within
// the number input.
func (this *NumberInput) OnConfirm (callback func ()) event.Cookie {
return this.on.confirm.Connect(callback)
}
func (this *NumberInput) shift (by int) {
@@ -94,7 +94,7 @@ func (this *NumberInput) handleScroll (x, y float64) {
}
}
func (this *NumberInput) handleEnter () {
func (this *NumberInput) handleConfirm () {
this.SetValue(this.Value())
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
}