mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:28:12 +00:00
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:
parent
15fad649ea
commit
069d21ed7f
15 changed files with 105 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue