Revert "Drop down list: stop using has_minimum="false" and remove a workaround"

This reverts commit 1e8d8ff7d7.

@CelticMinstrel and @Vultraz pointed out that the change causes menus
and dropdowns (which are implemented as dropdowns) to initially have
an item selected, which isn't desired.
This commit is contained in:
Jyrki Vesterinen 2017-02-16 20:46:48 +02:00
parent f70f1b37e4
commit 02f78600c1
2 changed files with 13 additions and 0 deletions

View file

@ -72,6 +72,7 @@ min(
[listbox]
id = "list"
definition = "default"
has_minimum = "false"
[list_definition]

View file

@ -61,6 +61,18 @@ namespace {
}
}
/* FIXME: This dialog uses a listbox with 'has_minimum = false'. This allows a listbox to have 0 or more selections,
* and selecting the same entry toggles that entry's state (ie, if it was selected, it will be deselected). Because
* of this, selecting the same entry in the dropdown list essentially sets the list's selected row to -1, causing problems.
*
* In order to work around this, we first manually deselect the selected entry here. This handler is called *before*
* the listbox's click handler, and as such the selected item will remain toggled on when the click handler fires.
*/
const int sel = list.get_selected_row();
if(sel >= 0) {
list.select_row(sel, false);
}
SDL_Rect rect = window.get_rectangle();
if(!sdl::point_in_rect(coordinate, rect)) {
window.set_retval(window::CANCEL);