forked from jojomi/gonsole
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbasecontrol.go
More file actions
46 lines (37 loc) · 769 Bytes
/
basecontrol.go
File metadata and controls
46 lines (37 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package gonsole
// Control is the base model for a UI control
type BaseControl struct {
BaseElement
focusable bool
cursorable bool
}
func (c *BaseControl) Focusable() bool {
return c.focusable
}
func (c *BaseControl) SetFocusable(focusable bool) {
c.focusable = focusable
}
func (c *BaseControl) Focused() bool {
if c.window.FocusedControl() != nil {
if c.window.FocusedControl().ID() == c.ID() {
return true
}
}
return false
}
func (c *BaseControl) Focus() {
c.window.FocusControl(c)
}
func (c *BaseControl) Cursorable() bool {
return c.cursorable
}
func (c *BaseControl) SetCursorable(cursorable bool) {
c.cursorable = cursorable
}
func (c *BaseControl) Repaint() {
if c.Focused() {
c.drawBox("focused.")
} else {
c.drawBox("")
}
}