mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
TextEditor: Hide the search bar until the user asks for it
You can get to it via Edit/Find, or by pressing Ctrl+F.
This commit is contained in:
parent
933a98f8fa
commit
96c5c9ce12
2 changed files with 9 additions and 0 deletions
|
@ -30,6 +30,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
find_widget->set_preferred_size(0, 22);
|
find_widget->set_preferred_size(0, 22);
|
||||||
find_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
find_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||||
find_widget->layout()->set_margins({ 2, 2, 2, 2 });
|
find_widget->layout()->set_margins({ 2, 2, 2, 2 });
|
||||||
|
find_widget->set_visible(false);
|
||||||
|
|
||||||
m_find_textbox = new GTextBox(find_widget);
|
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);
|
auto* statusbar = new GStatusBar(this);
|
||||||
|
|
||||||
m_editor->on_cursor_change = [statusbar, 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->copy_action());
|
||||||
edit_menu->add_action(m_editor->paste_action());
|
edit_menu->add_action(m_editor->paste_action());
|
||||||
edit_menu->add_action(m_editor->delete_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));
|
menubar->add_menu(move(edit_menu));
|
||||||
|
|
||||||
auto font_menu = make<GMenu>("Font");
|
auto font_menu = make<GMenu>("Font");
|
||||||
|
|
|
@ -28,6 +28,7 @@ private:
|
||||||
RefPtr<GAction> m_open_action;
|
RefPtr<GAction> m_open_action;
|
||||||
RefPtr<GAction> m_save_action;
|
RefPtr<GAction> m_save_action;
|
||||||
RefPtr<GAction> m_save_as_action;
|
RefPtr<GAction> m_save_as_action;
|
||||||
|
RefPtr<GAction> m_find_action;
|
||||||
|
|
||||||
GTextBox* m_find_textbox { nullptr };
|
GTextBox* m_find_textbox { nullptr };
|
||||||
GButton* m_find_button { nullptr };
|
GButton* m_find_button { nullptr };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue