Make buttons unpress when the cursor leaves the button rect.

Implement this functionality by adding global cursor tracking.
It's currently only possible for one GWidget per GWindow to track the cursor.
This commit is contained in:
Andreas Kling 2019-01-27 08:48:34 +01:00
commit 069d21ed7f
Notes: sideshowbarker 2024-07-19 15:56:04 +09:00
15 changed files with 105 additions and 7 deletions

View file

@ -170,3 +170,19 @@ void GWidget::set_font(RetainPtr<Font>&& font)
else
m_font = move(font);
}
void GWidget::set_global_cursor_tracking(bool enabled)
{
auto* win = window();
if (!win)
return;
win->set_global_cursor_tracking_widget(enabled ? this : nullptr);
}
bool GWidget::global_cursor_tracking() const
{
auto* win = window();
if (!win)
return false;
return win->global_cursor_tracking_widget() == this;
}