mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
Ensure ListWindow doesn't kill the selected item when an empty area is
clicked.
This commit is contained in:
parent
a9ea1acb8f
commit
0a3f1a4f68
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user