From b36d253dce737a188bff85891fc5b4c4341f6564 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 16 Jul 2014 16:11:17 +0200 Subject: Automatically select first item in list boxes If the selection is empty during listbox_load_items() and there is at least one item in the list, automatically select the first item. Signed-off-by: Lukas Fleischer --- src/listbox.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/listbox.c b/src/listbox.c index 5cdc9a1..853dc03 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -88,6 +88,9 @@ void listbox_load_items(struct listbox *lb, int item_count) lb->item_count = item_count; + if (item_count > 0 && lb->item_sel < 0) + lb->item_sel = 0; + if (lb->item_sel >= item_count) lb->item_sel = item_count - 1; -- cgit v1.2.3-70-g09d2