Update code for objects
This commit is contained in:
25
textinput.go
25
textinput.go
@@ -21,11 +21,12 @@ func NewTextInput (text string) *TextInput {
|
||||
this := &TextInput { TextBox: tomo.NewTextBox() }
|
||||
this.SetRole(tomo.R("objects", "TextInput"))
|
||||
this.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
|
||||
this.SetAttr(tomo.AOverflow(true, false))
|
||||
this.SetText(text)
|
||||
this.SetFocusable(true)
|
||||
this.SetSelectable(true)
|
||||
this.SetOverflow(true, false)
|
||||
this.OnKeyDown(this.handleKeyDown)
|
||||
this.OnKeyUp(this.handleKeyUp)
|
||||
this.OnScroll(this.handleScroll)
|
||||
return this
|
||||
}
|
||||
@@ -53,7 +54,15 @@ func (this *TextInput) OnValueChange (callback func ()) event.Cookie {
|
||||
return this.on.valueChange.Connect(callback)
|
||||
}
|
||||
|
||||
func (this *TextInput) handleKeyDown (catch func (), key input.Key, numpad bool) {
|
||||
// Type types a character at the current dot position.
|
||||
func (this *TextInput) Type (char rune) {
|
||||
dot := this.Dot()
|
||||
this.text, dot = text.Type(this.text, dot, rune(char))
|
||||
this.Select(dot)
|
||||
this.SetText(string(this.text))
|
||||
}
|
||||
|
||||
func (this *TextInput) handleKeyDown (key input.Key, numpad bool) bool {
|
||||
dot := this.Dot()
|
||||
modifiers := this.Window().Modifiers()
|
||||
word := modifiers.Control
|
||||
@@ -103,16 +112,14 @@ func (this *TextInput) handleKeyDown (catch func (), key input.Key, numpad bool)
|
||||
this.SetText(string(this.text))
|
||||
this.on.valueChange.Broadcast()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Type types a character at the current dot position.
|
||||
func (this *TextInput) Type (char rune) {
|
||||
dot := this.Dot()
|
||||
this.text, dot = text.Type(this.text, dot, rune(char))
|
||||
this.Select(dot)
|
||||
this.SetText(string(this.text))
|
||||
func (this *TextInput) handleKeyUp (key input.Key, numpad bool) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *TextInput) handleScroll (catch func (), x, y float64) {
|
||||
func (this *TextInput) handleScroll (x, y float64) bool {
|
||||
this.ScrollTo(this.ContentBounds().Min.Add(image.Pt(int(x), int(y))))
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user