Fix crash when selecting the selected item from a dropdown menu
This commit is contained in:
parent
296902d426
commit
6c2e2e9bf7
1 changed files with 8 additions and 0 deletions
|
@ -33,6 +33,14 @@ REGISTER_DIALOG(drop_down_list)
|
|||
namespace {
|
||||
void click_callback(twindow& window, bool&, bool&, tpoint coordinate)
|
||||
{
|
||||
// By deselecting any selected row here, we remove the possibility that the click actually deselects the row
|
||||
// and results in selected_item_ being set to -1.
|
||||
// It works because this handler is called *before* the listbox's click handler.
|
||||
tlistbox& list = find_widget<tlistbox>(&window, "list", true);
|
||||
int sel = list.get_selected_row();
|
||||
if(sel >= 0) {
|
||||
list.select_row(sel, false);
|
||||
}
|
||||
SDL_Rect rect = window.get_rectangle();
|
||||
if(coordinate.x < rect.x || coordinate.x > rect.x + rect.w || coordinate.y < rect.y || coordinate.y > rect.y + rect.h ) {
|
||||
window.set_retval(twindow::CANCEL);
|
||||
|
|
Loading…
Add table
Reference in a new issue