NewEdit creates and returns a pointer to a new edit widget
(width int, placeHolder string)
| 54 | |
| 55 | // NewEdit creates and returns a pointer to a new edit widget |
| 56 | func NewEdit(width int, placeHolder string) *Edit { |
| 57 | |
| 58 | ed := new(Edit) |
| 59 | ed.width = width |
| 60 | ed.placeHolder = placeHolder |
| 61 | |
| 62 | ed.styles = &StyleDefault().Edit |
| 63 | ed.text = "" |
| 64 | ed.MaxLength = 80 |
| 65 | ed.col = 0 |
| 66 | ed.focus = false |
| 67 | |
| 68 | ed.Label.initialize("", StyleDefault().Font) |
| 69 | ed.Label.Subscribe(OnKeyDown, ed.onKey) |
| 70 | ed.Label.Subscribe(OnKeyRepeat, ed.onKey) |
| 71 | ed.Label.Subscribe(OnChar, ed.onChar) |
| 72 | ed.Label.Subscribe(OnMouseDown, ed.onMouse) |
| 73 | ed.Label.Subscribe(OnCursorEnter, ed.onCursor) |
| 74 | ed.Label.Subscribe(OnCursorLeave, ed.onCursor) |
| 75 | ed.Label.Subscribe(OnEnable, func(evname string, ev interface{}) { ed.update() }) |
| 76 | ed.Subscribe(OnFocusLost, ed.OnFocusLost) |
| 77 | |
| 78 | ed.update() |
| 79 | return ed |
| 80 | } |
| 81 | |
| 82 | // SetText sets this edit text |
| 83 | func (ed *Edit) SetText(text string) *Edit { |
no test coverage detected