Merge pull request #531 from wesnoth/gfgtdf-patch-1

fix selected item after deletion in a ordered list
This commit is contained in:
gfgtdf 2015-10-17 17:32:20 +02:00
commit df3c4df5e8

View File

@ -74,14 +74,15 @@ void tone::delete_item(const unsigned index)
// Are there items left?
const unsigned item_count = get_item_count();
const unsigned visible_index = get_ordered_index(index);
if(item_count > 1) {
// Is the last item deselected?
if(index == item_count - 1) {
if(visible_index == item_count - 1) {
// Select the second last.
do_select_item(index - 1);
do_select_item(get_item_at_ordered(visible_index - 1));
} else {
// Select the next item.
do_select_item(index + 1);
do_select_item(get_item_at_ordered(visible_index + 1));
}
}
}