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

Has_minimum="false" caused the following bug:

1. In a dropdown with toggle buttons, select any entry.
2. Close the dropdown and open it again.
3. Deselecting the entry selected in 1 is now impossible.

This commit fixes the bug above and addresses a FIXME.
This commit is contained in:
Jyrki Vesterinen 2017-02-16 20:37:50 +02:00
parent 5b4482f7a8
commit 1e8d8ff7d7
2 changed files with 0 additions and 13 deletions

View file

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

View file

@ -61,18 +61,6 @@ 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);