parent
638fc61d83
commit
1125d98b3d
@ -54,10 +54,10 @@ func (this *LabelSwatch) RGBA () (r, g, b, a uint32) {
|
|||||||
return this.swatch.RGBA()
|
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.
|
// color picker.
|
||||||
func (this *LabelSwatch) OnEnter (callback func ()) event.Cookie {
|
func (this *LabelSwatch) OnConfirm (callback func ()) event.Cookie {
|
||||||
return this.swatch.OnEnter(callback)
|
return this.swatch.OnConfirm(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *LabelSwatch) handleMouseUp (button input.Button) {
|
func (this *LabelSwatch) handleMouseUp (button input.Button) {
|
||||||
|
@ -15,8 +15,8 @@ type NumberInput struct {
|
|||||||
increment *Button
|
increment *Button
|
||||||
decrement *Button
|
decrement *Button
|
||||||
on struct {
|
on struct {
|
||||||
enter event.FuncBroadcaster
|
|
||||||
valueChange event.FuncBroadcaster
|
valueChange event.FuncBroadcaster
|
||||||
|
confirm event.FuncBroadcaster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ func NewNumberInput (value float64) *NumberInput {
|
|||||||
|
|
||||||
box.OnScroll(box.handleScroll)
|
box.OnScroll(box.handleScroll)
|
||||||
box.OnKeyDown(box.handleKeyDown)
|
box.OnKeyDown(box.handleKeyDown)
|
||||||
box.input.OnEnter(box.handleEnter)
|
box.input.OnConfirm(box.handleConfirm)
|
||||||
box.input.OnValueChange(box.on.valueChange.Broadcast)
|
box.input.OnValueChange(box.on.valueChange.Broadcast)
|
||||||
box.increment.OnClick(func () { box.shift(1) })
|
box.increment.OnClick(func () { box.shift(1) })
|
||||||
box.decrement.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)
|
return this.on.valueChange.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnEnter specifies a function to be called when the user presses enter within
|
// OnConfirm specifies a function to be called when the user presses enter within
|
||||||
// the text input.
|
// the number input.
|
||||||
func (this *NumberInput) OnEnter (callback func ()) event.Cookie {
|
func (this *NumberInput) OnConfirm (callback func ()) event.Cookie {
|
||||||
return this.on.enter.Connect(callback)
|
return this.on.confirm.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *NumberInput) shift (by int) {
|
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.SetValue(this.Value())
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
}
|
}
|
||||||
|
20
slider.go
20
slider.go
@ -17,7 +17,7 @@ type Slider struct {
|
|||||||
|
|
||||||
on struct {
|
on struct {
|
||||||
valueChange event.FuncBroadcaster
|
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)
|
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.
|
// slider.
|
||||||
func (this *Slider) OnEnter (callback func ()) event.Cookie {
|
func (this *Slider) OnConfirm (callback func ()) event.Cookie {
|
||||||
return this.on.enter.Connect(callback)
|
return this.on.confirm.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
|
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
|
||||||
@ -155,21 +155,21 @@ func (this *Slider) handleMouseDown (button input.Button) {
|
|||||||
if above {
|
if above {
|
||||||
this.SetValue(0)
|
this.SetValue(0)
|
||||||
this.on.valueChange.Broadcast()
|
this.on.valueChange.Broadcast()
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(1)
|
this.SetValue(1)
|
||||||
this.on.valueChange.Broadcast()
|
this.on.valueChange.Broadcast()
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
}
|
}
|
||||||
case input.ButtonRight:
|
case input.ButtonRight:
|
||||||
if above {
|
if above {
|
||||||
this.SetValue(this.Value() - this.step)
|
this.SetValue(this.Value() - this.step)
|
||||||
this.on.valueChange.Broadcast()
|
this.on.valueChange.Broadcast()
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(this.Value() + this.step)
|
this.SetValue(this.Value() + this.step)
|
||||||
this.on.valueChange.Broadcast()
|
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) {
|
func (this *Slider) handleMouseUp (button input.Button) {
|
||||||
if button != input.ButtonLeft || !this.dragging { return }
|
if button != input.ButtonLeft || !this.dragging { return }
|
||||||
this.dragging = false
|
this.dragging = false
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Slider) handleMouseMove () {
|
func (this *Slider) handleMouseMove () {
|
||||||
@ -189,7 +189,7 @@ func (this *Slider) handleScroll (x, y float64) {
|
|||||||
delta := (x + y) * 0.005
|
delta := (x + y) * 0.005
|
||||||
this.SetValue(this.Value() + delta)
|
this.SetValue(this.Value() + delta)
|
||||||
this.on.valueChange.Broadcast()
|
this.on.valueChange.Broadcast()
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Slider) drag () {
|
func (this *Slider) drag () {
|
||||||
|
10
swatch.go
10
swatch.go
@ -17,7 +17,7 @@ type Swatch struct {
|
|||||||
label string
|
label string
|
||||||
on struct {
|
on struct {
|
||||||
valueChange event.FuncBroadcaster
|
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()
|
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.
|
// color picker.
|
||||||
func (this *Swatch) OnEnter (callback func ()) event.Cookie {
|
func (this *Swatch) OnConfirm (callback func ()) event.Cookie {
|
||||||
return this.on.enter.Connect(callback)
|
return this.on.confirm.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose creates a modal that allows the user to edit the color of the swatch.
|
// Choose creates a modal that allows the user to edit the color of the swatch.
|
||||||
@ -124,7 +124,7 @@ func (this *Swatch) Choose () {
|
|||||||
controlRow))
|
controlRow))
|
||||||
window.OnClose(func () {
|
window.OnClose(func () {
|
||||||
if committed {
|
if committed {
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
} else {
|
} else {
|
||||||
this.userSetValue(colorMemory)
|
this.userSetValue(colorMemory)
|
||||||
}
|
}
|
||||||
|
12
textinput.go
12
textinput.go
@ -11,8 +11,8 @@ type TextInput struct {
|
|||||||
tomo.TextBox
|
tomo.TextBox
|
||||||
text []rune
|
text []rune
|
||||||
on struct {
|
on struct {
|
||||||
enter event.FuncBroadcaster
|
|
||||||
valueChange event.FuncBroadcaster
|
valueChange event.FuncBroadcaster
|
||||||
|
confirm event.FuncBroadcaster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,10 +41,10 @@ func (this *TextInput) Text () string {
|
|||||||
return string(this.text)
|
return string(this.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnEnter specifies a function to be called when the user presses enter within
|
// OnConfirm specifies a function to be called when the user presses enter
|
||||||
// the text input.
|
// within the text input.
|
||||||
func (this *TextInput) OnEnter (callback func ()) event.Cookie {
|
func (this *TextInput) OnConfirm (callback func ()) event.Cookie {
|
||||||
return this.on.enter.Connect(callback)
|
return this.on.confirm.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnValueChange specifies a function to be called when the user edits the input
|
// 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 {
|
switch {
|
||||||
case key == input.KeyEnter:
|
case key == input.KeyEnter:
|
||||||
this.on.enter.Broadcast()
|
this.on.confirm.Broadcast()
|
||||||
case key == input.KeyHome || (modifiers.Alt && key == input.KeyLeft):
|
case key == input.KeyHome || (modifiers.Alt && key == input.KeyLeft):
|
||||||
dot.End = 0
|
dot.End = 0
|
||||||
if !sel { dot.Start = dot.End }
|
if !sel { dot.Start = dot.End }
|
||||||
|
Loading…
Reference in New Issue
Block a user