diff options
author | angel <angel@ttm.sh> | 2020-04-20 21:10:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-20 22:43:40 +0200 |
commit | 441c2715bbb50e0063e827ae37c40f58865993d6 (patch) | |
tree | ef52dcf5661deab24b3d2aaa2bef34074343cc7f /Libraries/LibGUI/TextEditor.cpp | |
parent | 563a377f6b5da578673f7c645d6f904505148cc1 (diff) | |
download | serenity-441c2715bbb50e0063e827ae37c40f58865993d6.zip |
LibGUI: Add Select all action to TextEditor
Previously, TextEditor processed the Select all command directly on the
keydown event handler. For this reason, WindowManager would not process
it as an action for the focused control and an action with the same
keyboard shortcut from the parent could override the TextEditor's one
even when it is focused.
For instance, when pressing Ctrl+A on the FileManager's path bar, all
files were selected instead, which is not the expected behavior.
Now the Select all command is an actual action on TextEditor, so that
WindowManager can process it correctly before any other actions. I also
added an icon for it!
Diffstat (limited to 'Libraries/LibGUI/TextEditor.cpp')
-rw-r--r-- | Libraries/LibGUI/TextEditor.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp index 967ab401ec..86295b37e1 100644 --- a/Libraries/LibGUI/TextEditor.cpp +++ b/Libraries/LibGUI/TextEditor.cpp @@ -98,6 +98,8 @@ void TextEditor::create_actions() }, this); } + m_select_all_action = Action::create( + "Select all", { Mod_Ctrl, Key_A },Gfx::Bitmap::load_from_file("/res/icons/16x16/select-all.png"), [this](auto&) { select_all(); }, this); } void TextEditor::set_text(const StringView& text) @@ -812,10 +814,6 @@ void TextEditor::keydown_event(KeyEvent& event) } return; } - if (event.modifiers() == Mod_Ctrl && event.key() == KeyCode::Key_A) { - select_all(); - return; - } if (event.alt() && event.shift() && event.key() == KeyCode::Key_S) { sort_selected_lines(); return; @@ -1277,6 +1275,8 @@ void TextEditor::context_menu_event(ContextMenuEvent& event) m_context_menu->add_action(copy_action()); m_context_menu->add_action(paste_action()); m_context_menu->add_action(delete_action()); + m_context_menu->add_separator(); + m_context_menu->add_action(select_all_action()); if (is_multi_line()) { m_context_menu->add_separator(); m_context_menu->add_action(go_to_line_action()); |