diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 85941be96cc..8e805208959 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -30,6 +30,7 @@ TextEditorWidget::TextEditorWidget() find_widget->set_preferred_size(0, 22); find_widget->set_layout(make(Orientation::Horizontal)); find_widget->layout()->set_margins({ 2, 2, 2, 2 }); + find_widget->set_visible(false); m_find_textbox = new GTextBox(find_widget); @@ -52,6 +53,11 @@ TextEditorWidget::TextEditorWidget() } }; + m_find_action = GAction::create("Find...", { Mod_Ctrl, Key_F }, [this, find_widget](auto&) { + find_widget->set_visible(true); + m_find_textbox->set_focus(true); + }); + auto* statusbar = new GStatusBar(this); m_editor->on_cursor_change = [statusbar, this] { @@ -120,6 +126,8 @@ TextEditorWidget::TextEditorWidget() edit_menu->add_action(m_editor->copy_action()); edit_menu->add_action(m_editor->paste_action()); edit_menu->add_action(m_editor->delete_action()); + edit_menu->add_separator(); + edit_menu->add_action(*m_find_action); menubar->add_menu(move(edit_menu)); auto font_menu = make("Font"); diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h index c8e7c1e28d6..d8dab467776 100644 --- a/Applications/TextEditor/TextEditorWidget.h +++ b/Applications/TextEditor/TextEditorWidget.h @@ -28,6 +28,7 @@ private: RefPtr m_open_action; RefPtr m_save_action; RefPtr m_save_as_action; + RefPtr m_find_action; GTextBox* m_find_textbox { nullptr }; GButton* m_find_button { nullptr };