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 <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-07-16 16:11:17 +02:00
parent 6550591b08
commit b36d253dce

View File

@ -88,6 +88,9 @@ void listbox_load_items(struct listbox *lb, int item_count)
lb->item_count = 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) if (lb->item_sel >= item_count)
lb->item_sel = item_count - 1; lb->item_sel = item_count - 1;