mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 21:05:07 +00:00
LibGUI: Hide the tooltip if widget with open tooltip unsets it
If you call set_tooltip({}) on a widget currently showing a tooltip, we will now remove the tooltip window from screen.
This commit is contained in:
parent
a0f2135f47
commit
347e5aa7b5
2 changed files with 8 additions and 6 deletions
|
@ -387,7 +387,7 @@ void Widget::handle_enter_event(Core::Event& event)
|
||||||
{
|
{
|
||||||
if (auto* window = this->window())
|
if (auto* window = this->window())
|
||||||
window->update_cursor({});
|
window->update_cursor({});
|
||||||
show_tooltip();
|
show_or_hide_tooltip();
|
||||||
enter_event(event);
|
enter_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,14 +905,16 @@ Gfx::IntRect Widget::content_rect() const
|
||||||
void Widget::set_tooltip(const StringView& tooltip)
|
void Widget::set_tooltip(const StringView& tooltip)
|
||||||
{
|
{
|
||||||
m_tooltip = tooltip;
|
m_tooltip = tooltip;
|
||||||
if (GUI::Application::the()->tooltip_source_widget() == this)
|
if (Application::the()->tooltip_source_widget() == this)
|
||||||
show_tooltip();
|
show_or_hide_tooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::show_tooltip()
|
void Widget::show_or_hide_tooltip()
|
||||||
{
|
{
|
||||||
if (has_tooltip())
|
if (has_tooltip())
|
||||||
Application::the()->show_tooltip(m_tooltip, this);
|
Application::the()->show_tooltip(m_tooltip, this);
|
||||||
|
else
|
||||||
|
Application::the()->hide_tooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::IntRect Widget::children_clip_rect() const
|
Gfx::IntRect Widget::children_clip_rect() const
|
||||||
|
|
|
@ -328,6 +328,8 @@ protected:
|
||||||
virtual void did_begin_inspection() override;
|
virtual void did_begin_inspection() override;
|
||||||
virtual void did_end_inspection() override;
|
virtual void did_end_inspection() override;
|
||||||
|
|
||||||
|
void show_or_hide_tooltip();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handle_paint_event(PaintEvent&);
|
void handle_paint_event(PaintEvent&);
|
||||||
void handle_resize_event(ResizeEvent&);
|
void handle_resize_event(ResizeEvent&);
|
||||||
|
@ -339,8 +341,6 @@ private:
|
||||||
void focus_previous_widget(FocusSource, bool siblings_only);
|
void focus_previous_widget(FocusSource, bool siblings_only);
|
||||||
void focus_next_widget(FocusSource, bool siblings_only);
|
void focus_next_widget(FocusSource, bool siblings_only);
|
||||||
|
|
||||||
void show_tooltip();
|
|
||||||
|
|
||||||
bool load_from_json(const JsonObject&);
|
bool load_from_json(const JsonObject&);
|
||||||
|
|
||||||
// HACK: These are used as property getters for the fixed_* size property aliases.
|
// HACK: These are used as property getters for the fixed_* size property aliases.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue