~chrisppy/beagles

fbdff3ecfc2d13d595fe3be9af1a3e6e211e74ce — Chris Palmer 23 days ago 7f9276b
Add list functions for set index by key
1 files changed, 10 insertions(+), 5 deletions(-)

M ui/list.go
M ui/list.go => ui/list.go +10 -5
@@ 75,6 75,10 @@ func (w *list) setIndex(newIndex int) {
	w.Widget.SetCurrentItem(newIndex)
}

func (w *list) setIndexByKey(key string) {
	w.setIndex(w.find(key))
}

func (w *list) index() int {
	return w.Widget.GetCurrentItem()
}


@@ 92,13 96,14 @@ func (w *list) remove() string {
	return key
}

func (w *list) removeByKey(key string) {
func (w *list) find(key string) int {
	indices := w.Widget.FindItems("", key, false, false)
	return indices[0]
}

	if len(indices) == 1 {
		w.setIndex(indices[0])
		w.remove()
	}
func (w *list) removeByKey(key string) {
	w.setIndex(w.find(key))
	w.remove()
}

func (w *list) add(item *db.Item) {