Ensure ListWindow doesn't kill the selected item when an empty area is

clicked.
This commit is contained in:
casey langen 2018-06-22 12:48:56 -07:00
parent a9ea1acb8f
commit 0a3f1a4f68

View File

@ -298,6 +298,7 @@ bool ListWindow::KeyPress(const std::string& key) {
}
bool ListWindow::MouseEvent(const IMouseHandler::Event& event) {
/* CAL TODO: this method assumes each row is a single cell tall. */
bool result = ScrollableWindow::MouseEvent(event);
auto first = this->scrollPosition.firstVisibleEntryIndex;
@ -308,13 +309,15 @@ bool ListWindow::MouseEvent(const IMouseHandler::Event& event) {
size_t offset = first + (size_t) event.y;
if (event.Button1Clicked()) {
this->SetSelectedIndex(offset);
}
else if (event.Button1DoubleClicked()) {
this->FocusInParent();
this->SetSelectedIndex(offset);
this->OnEntryActivated(offset); /* internal */
if (offset < this->GetScrollAdapter().GetEntryCount()) {
if (event.Button1Clicked()) {
this->SetSelectedIndex(offset);
}
else if (event.Button1DoubleClicked()) {
this->FocusInParent();
this->SetSelectedIndex(offset);
this->OnEntryActivated(offset); /* internal */
}
}
return result;