void Listbox::OnMousePress(vec2 mousePos, int button, bool down) { if (down) lastScrollUpdate = OS::Now(); else { lastScrollUpdate = 0; lastScrollPos = vec2(-1,-1); //Mouse up, check if they selected something //Use the hovering over calculation stolen from the draw phase int hoveringOver = (int)((lastMousePos.y-scrollPosition-3)/entryHeight); //Check that the cursor is not in the scroll bar bool scrollBarNeeded = (entryHeight*entries.size() > position.Height-6); if (scrollBarNeeded) { if (lastMousePos.x >= calculatedPosition.Width-3-scrollButtonWidth) hoveringOver = -1; } if ((hoveringOver < 0) || (hoveringOver >= (int)entries.size())) return; else { if (selected == hoveringOver) { if ((OS::Now() - selectedAt) < .35) { //Double clicked list item EventSelectionDoubleClicked.Fire([this](function<void(Listbox*,int)> subscriber) { subscriber(this,this->selected); }); } selectedAt = OS::Now(); } else { selectedAt = OS::Now(); selected = hoveringOver; OnListSelected(); } } } }
void CBOINCBaseView::FireOnListSelected(wxListEvent& event) { OnListSelected(event); }