Added Datepicker
Some other work too
This commit is contained in:
@@ -88,14 +88,15 @@ func (w *LinearLayout) Init(id string, s tcell.Style) {
|
||||
w.keyMap.Add(tcell.KeyTab, func(ev *tcell.EventKey) bool {
|
||||
active := w.findActive()
|
||||
if active == nil && len(w.widgets) > 0 {
|
||||
// No widget is active
|
||||
// No widget is active, but we do have some
|
||||
|
||||
if w.widgets[0].Focusable() {
|
||||
w.widgets[0].SetActive(true)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return w.activateNext()
|
||||
return w.ActivateNext()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -122,13 +123,16 @@ func (w *LinearLayout) HandleKey(ev *tcell.EventKey) bool {
|
||||
}
|
||||
active := w.findActive()
|
||||
if active != nil {
|
||||
w.Log("LL(%s) Active(%s) Handlekey", w.Id(), active.Id())
|
||||
if active.HandleKey(ev) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return w.keyMap.Handle(ev)
|
||||
}
|
||||
func (w *LinearLayout) GetActive() Widget { return w.findActive() }
|
||||
|
||||
func (w *LinearLayout) GetActiveWidgetIdx() int { return w.findActiveIdx() }
|
||||
func (w *LinearLayout) GetActiveWidget() Widget { return w.findActive() }
|
||||
|
||||
func (w *LinearLayout) HandleTime(ev *tcell.EventTime) {
|
||||
for _, wi := range w.widgets {
|
||||
@@ -242,6 +246,15 @@ func (w *LinearLayout) MinH() int {
|
||||
}
|
||||
|
||||
// Find the currently active widget, there should be only one.
|
||||
func (w *LinearLayout) findActiveIdx() int {
|
||||
for i := range w.widgets {
|
||||
if w.widgets[i].Active() {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func (w *LinearLayout) findActive() Widget {
|
||||
for i := range w.widgets {
|
||||
if w.widgets[i].Active() {
|
||||
@@ -262,7 +275,7 @@ func (w *LinearLayout) findActiveOrFirst() Widget {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *LinearLayout) activateNext() bool {
|
||||
func (w *LinearLayout) ActivateNext() bool {
|
||||
var found bool
|
||||
for i := range w.widgets {
|
||||
if found && w.widgets[i].Focusable() {
|
||||
@@ -276,6 +289,20 @@ func (w *LinearLayout) activateNext() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *LinearLayout) ActivatePrev() bool {
|
||||
var found bool
|
||||
for i := len(w.widgets) - 1; i >= 0; i-- {
|
||||
if found && w.widgets[i].Focusable() {
|
||||
w.widgets[i].SetActive(true)
|
||||
return true
|
||||
} else if w.widgets[i].Active() {
|
||||
found = true
|
||||
w.widgets[i].SetActive(false)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *LinearLayout) SetOrientation(o LinearLayoutOrient) { w.orientation = o }
|
||||
func (w *LinearLayout) IndexOf(n Widget) int {
|
||||
for i := range w.widgets {
|
||||
|
||||
Reference in New Issue
Block a user