Improve select all saves feature (fixes #725)

Ctrl+A no longer selects all saves if any of the textboxes in
the view are in focus, as a ctrl+A in that case is expected to
select everything in the textbox, not in the save browser.

This change also makes the shortcut deselect all saves if all
saves are selected.

And no, I'm not making events cancellable just for this.
This commit is contained in:
Tamás Bálint Misius 2020-08-07 00:01:30 +02:00
parent dd46bf7d42
commit 6ec87ed1ed
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 13 additions and 3 deletions

View File

@ -201,9 +201,19 @@ void SearchModel::SelectSave(int saveID)
void SearchModel::SelectAllSaves()
{
for (int i = 0; i < saveList.size(); i++)
if (selected.size() == saveList.size())
{
SelectSave(saveList[i]->id);
for (auto &save : saveList)
{
DeselectSave(save->id);
}
}
else
{
for (auto &save : saveList)
{
SelectSave(save->id);
}
}
}

View File

@ -654,7 +654,7 @@ void SearchView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctr
return;
if (key == SDLK_ESCAPE)
c->Exit();
else if (key == SDLK_a && ctrl)
else if ((focusedComponent_ != pageTextbox && focusedComponent_ != searchField) && scan == SDL_SCANCODE_A && ctrl)
c->SelectAllSaves();
else if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->InstantOpen(true);