12
textinput.go
12
textinput.go
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user