summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-20 18:16:04 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-20 18:16:04 +0100
commitf0915641c58295b8f117d04845d31724aae86ea6 (patch)
tree84bb6794d936a143b0cf78c27ccea3d7349fb852
parentdaa1dcb5e8612da1aae8eaa146153a25e90dc60f (diff)
downloadserenity-f0915641c58295b8f117d04845d31724aae86ea6.zip
TextEditor: Add "delete" action.
-rw-r--r--Applications/TextEditor/main.cpp6
-rw-r--r--LibGUI/GTextEditor.h2
2 files changed, 7 insertions, 1 deletions
diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp
index 16023de124..71ae2ad5d1 100644
--- a/Applications/TextEditor/main.cpp
+++ b/Applications/TextEditor/main.cpp
@@ -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();
diff --git a/LibGUI/GTextEditor.h b/LibGUI/GTextEditor.h
index 9b1ddcf904..ad662133ad 100644
--- a/LibGUI/GTextEditor.h
+++ b/LibGUI/GTextEditor.h
@@ -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 };