MCPcopy Index your code
hub / github.com/g3n/engine / NewEdit

Function NewEdit

gui/edit.go:56–80  ·  view source on GitHub ↗

NewEdit creates and returns a pointer to a new edit widget

(width int, placeHolder string)

Source from the content-addressed store, hash-verified

54
55// NewEdit creates and returns a pointer to a new edit widget
56func 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
83func (ed *Edit) SetText(text string) *Edit {

Callers 1

buildEditFunction · 0.85

Calls 4

StyleDefaultFunction · 0.85
SubscribeMethod · 0.65
initializeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected