TextBox now has an OnEnter method.
This commit is contained in:
parent
221647a265
commit
d475e5e2ec
@ -34,6 +34,7 @@ type TextBox struct {
|
||||
|
||||
onKeyDown func (key input.Key, modifiers input.Modifiers) (handled bool)
|
||||
onChange func ()
|
||||
onEnter func ()
|
||||
onScrollBoundsChange func ()
|
||||
}
|
||||
|
||||
@ -124,6 +125,11 @@ func (element *TextBox) HandleKeyDown(key input.Key, modifiers input.Modifiers)
|
||||
altered := true
|
||||
textChanged := false
|
||||
switch {
|
||||
case key == input.KeyEnter:
|
||||
if element.onEnter != nil {
|
||||
element.onEnter()
|
||||
}
|
||||
|
||||
case key == input.KeyBackspace:
|
||||
if len(element.text) < 1 { break }
|
||||
element.text, element.dot = textmanip.Backspace (
|
||||
@ -236,6 +242,10 @@ func (element *TextBox) OnKeyDown (
|
||||
element.onKeyDown = callback
|
||||
}
|
||||
|
||||
func (element *TextBox) OnEnter (callback func ()) {
|
||||
element.onEnter = callback
|
||||
}
|
||||
|
||||
func (element *TextBox) OnChange (callback func ()) {
|
||||
element.onChange = callback
|
||||
}
|
||||
|
Reference in New Issue
Block a user