package input import ( "github.com/vugu/vugu" ) // TextArea is a text or number based input component. // The HTML input type is determined by the bound data type. type TextArea struct { AttrMap vugu.AttrMap Bind ValueBinder Input InputHandler // External handler that is called upon an event. KeyDown KeyDownHandler // External handler that is called upon an event. KeyPress KeyPressHandler // External handler that is called upon an event. KeyUp KeyUpHandler // External handler that is called upon an event. } func (c *TextArea) content() string { if c.Bind != nil { return c.Bind.StringValue() } return "" } func (c *TextArea) handleInput(event vugu.DOMEvent) { val := event.PropString("target", "value") if c.Bind != nil { c.Bind.SetStringValue(val) // TODO: Error is omitted, we should show it } if c.Input != nil { c.Input.InputHandle(InputEvent{event}) } } func (c *TextArea) handleKeyDown(event vugu.DOMEvent) { if c.KeyDown != nil { c.KeyDown.KeyDownHandle(KeyDownEvent{event}) } } func (c *TextArea) handleKeyPress(event vugu.DOMEvent) { if c.KeyPress != nil { c.KeyPress.KeyPressHandle(KeyPressEvent{event}) } } func (c *TextArea) handleKeyUp(event vugu.DOMEvent) { if c.KeyUp != nil { c.KeyUp.KeyUpHandle(KeyUpEvent{event}) } }