Change OnEnter to OnConfirm

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

View File

@ -54,10 +54,10 @@ func (this *LabelSwatch) RGBA () (r, g, b, a uint32) {
return this.swatch.RGBA()
}
// OnEnter specifies a function to be called when the user selects "OK" in the
// OnConfirm specifies a function to be called when the user selects "OK" in the
// color picker.
func (this *LabelSwatch) OnEnter (callback func ()) event.Cookie {
return this.swatch.OnEnter(callback)
func (this *LabelSwatch) OnConfirm (callback func ()) event.Cookie {
return this.swatch.OnConfirm(callback)
}
func (this *LabelSwatch) handleMouseUp (button input.Button) {

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()
}

View File

@ -17,7 +17,7 @@ type Slider struct {
on struct {
valueChange event.FuncBroadcaster
enter event.FuncBroadcaster
confirm event.FuncBroadcaster
}
}
@ -90,10 +90,10 @@ func (this *Slider) OnValueChange (callback func ()) event.Cookie {
return this.on.valueChange.Connect(callback)
}
// OnEnter specifies a function to be called when the user stops moving the
// OnConfirm specifies a function to be called when the user stops moving the
// slider.
func (this *Slider) OnEnter (callback func ()) event.Cookie {
return this.on.enter.Connect(callback)
func (this *Slider) OnConfirm (callback func ()) event.Cookie {
return this.on.confirm.Connect(callback)
}
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
@ -155,21 +155,21 @@ func (this *Slider) handleMouseDown (button input.Button) {
if above {
this.SetValue(0)
this.on.valueChange.Broadcast()
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
} else {
this.SetValue(1)
this.on.valueChange.Broadcast()
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
}
case input.ButtonRight:
if above {
this.SetValue(this.Value() - this.step)
this.on.valueChange.Broadcast()
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
} else {
this.SetValue(this.Value() + this.step)
this.on.valueChange.Broadcast()
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
}
}
}
@ -177,7 +177,7 @@ func (this *Slider) handleMouseDown (button input.Button) {
func (this *Slider) handleMouseUp (button input.Button) {
if button != input.ButtonLeft || !this.dragging { return }
this.dragging = false
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
}
func (this *Slider) handleMouseMove () {
@ -189,7 +189,7 @@ func (this *Slider) handleScroll (x, y float64) {
delta := (x + y) * 0.005
this.SetValue(this.Value() + delta)
this.on.valueChange.Broadcast()
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
}
func (this *Slider) drag () {

View File

@ -17,7 +17,7 @@ type Swatch struct {
label string
on struct {
valueChange event.FuncBroadcaster
enter event.FuncBroadcaster
confirm event.FuncBroadcaster
}
}
@ -60,10 +60,10 @@ func (this *Swatch) RGBA () (r, g, b, a uint32) {
return this.value.RGBA()
}
// OnEnter specifies a function to be called when the user selects "OK" in the
// OnConfirm specifies a function to be called when the user selects "OK" in the
// color picker.
func (this *Swatch) OnEnter (callback func ()) event.Cookie {
return this.on.enter.Connect(callback)
func (this *Swatch) OnConfirm (callback func ()) event.Cookie {
return this.on.confirm.Connect(callback)
}
// Choose creates a modal that allows the user to edit the color of the swatch.
@ -124,7 +124,7 @@ func (this *Swatch) Choose () {
controlRow))
window.OnClose(func () {
if committed {
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
} else {
this.userSetValue(colorMemory)
}

View File

@ -11,8 +11,8 @@ type TextInput struct {
tomo.TextBox
text []rune
on struct {
enter event.FuncBroadcaster
valueChange event.FuncBroadcaster
confirm event.FuncBroadcaster
}
}
@ -41,10 +41,10 @@ func (this *TextInput) Text () string {
return string(this.text)
}
// OnEnter specifies a function to be called when the user presses enter within
// the text input.
func (this *TextInput) 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 text input.
func (this *TextInput) OnConfirm (callback func ()) event.Cookie {
return this.on.confirm.Connect(callback)
}
// OnValueChange specifies a function to be called when the user edits the input
@ -65,7 +65,7 @@ func (this *TextInput) handleKeyDown (key input.Key, numpad bool) {
switch {
case key == input.KeyEnter:
this.on.enter.Broadcast()
this.on.confirm.Broadcast()
case key == input.KeyHome || (modifiers.Alt && key == input.KeyLeft):
dot.End = 0
if !sel { dot.Start = dot.End }