From e67f392576d35b0f86de2b2781f180691f915be6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 17 Apr 2021 18:44:45 +0200 Subject: [PATCH] TextEditor: Show action long texts in the status bar :^) We now display a description of the currently hovered action in the text editor application's status bar. This is pretty cool! :^) This is currentl achieved via the hooks on GUI::Application. Longer term we'll probably want to find a more flexible abstraction for this, since not all applications will be as simple as TextEditor. --- .../Applications/TextEditor/TextEditorWidget.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Userland/Applications/TextEditor/TextEditorWidget.cpp b/Userland/Applications/TextEditor/TextEditorWidget.cpp index c52e50d0a7..0b21b54081 100644 --- a/Userland/Applications/TextEditor/TextEditorWidget.cpp +++ b/Userland/Applications/TextEditor/TextEditorWidget.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -274,6 +275,17 @@ TextEditorWidget::TextEditorWidget() m_statusbar = *find_descendant_of_type_named("statusbar"); + GUI::Application::the()->on_action_enter = [this](GUI::Action& action) { + auto text = action.long_text(); + if (text.is_empty()) + text = Gfx::parse_ampersand_string(action.text()); + m_statusbar->set_override_text(move(text)); + }; + + GUI::Application::the()->on_action_leave = [this](GUI::Action&) { + m_statusbar->set_override_text({}); + }; + m_editor->on_cursor_change = [this] { update_statusbar(); }; m_editor->on_selection_change = [this] { update_statusbar(); };