mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
LibGUI: Clear any hovered index when the cursor leaves an AbstractView
This commit is contained in:
parent
c26bef0e53
commit
031d242e0e
3 changed files with 19 additions and 5 deletions
|
@ -193,16 +193,27 @@ void AbstractView::mousedown_event(MouseEvent& event)
|
|||
update();
|
||||
}
|
||||
|
||||
void AbstractView::set_hovered_index(const ModelIndex& index)
|
||||
{
|
||||
if (m_hovered_index == index)
|
||||
return;
|
||||
m_hovered_index = index;
|
||||
update();
|
||||
}
|
||||
|
||||
void AbstractView::leave_event(Core::Event& event)
|
||||
{
|
||||
ScrollableWidget::leave_event(event);
|
||||
set_hovered_index({});
|
||||
}
|
||||
|
||||
void AbstractView::mousemove_event(MouseEvent& event)
|
||||
{
|
||||
if (!model())
|
||||
return ScrollableWidget::mousemove_event(event);
|
||||
|
||||
auto hovered_index = index_at_event_position(event.position());
|
||||
if (m_hovered_index != hovered_index) {
|
||||
m_hovered_index = hovered_index;
|
||||
update();
|
||||
}
|
||||
set_hovered_index(hovered_index);
|
||||
|
||||
if (!m_might_drag)
|
||||
return ScrollableWidget::mousemove_event(event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue