mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 22:25:08 +00:00
TextEditor: Add "delete" action.
This commit is contained in:
parent
daa1dcb5e8
commit
f0915641c5
2 changed files with 7 additions and 1 deletions
|
@ -77,6 +77,10 @@ int main(int argc, char** argv)
|
|||
text_editor->paste();
|
||||
});
|
||||
|
||||
auto delete_action = GAction::create("Delete", { 0, Key_Delete }, GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/16x16/delete.rgb", { 16, 16 }), [&] (const GAction&) {
|
||||
text_editor->delete_selection();
|
||||
});
|
||||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = make<GMenu>("TextEditor");
|
||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) {
|
||||
|
@ -98,6 +102,7 @@ int main(int argc, char** argv)
|
|||
edit_menu->add_action(cut_action.copy_ref());
|
||||
edit_menu->add_action(copy_action.copy_ref());
|
||||
edit_menu->add_action(paste_action.copy_ref());
|
||||
edit_menu->add_action(delete_action.copy_ref());
|
||||
menubar->add_menu(move(edit_menu));
|
||||
|
||||
auto font_menu = make<GMenu>("Font");
|
||||
|
@ -126,6 +131,7 @@ int main(int argc, char** argv)
|
|||
toolbar->add_action(move(cut_action));
|
||||
toolbar->add_action(move(copy_action));
|
||||
toolbar->add_action(move(paste_action));
|
||||
toolbar->add_action(move(delete_action));
|
||||
|
||||
toolbar->add_separator();
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void delete_selection();
|
||||
|
||||
Function<void(GTextEditor&)> on_return_pressed;
|
||||
Function<void(GTextEditor&)> on_escape_pressed;
|
||||
|
@ -149,7 +150,6 @@ private:
|
|||
Rect ruler_content_rect(int line) const;
|
||||
void toggle_selection_if_needed_for_event(const GKeyEvent&);
|
||||
void insert_at_cursor_or_replace_selection(const String&);
|
||||
void delete_selection();
|
||||
|
||||
Type m_type { MultiLine };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue