mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 10:14:58 +00:00
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!
This commit is contained in:
parent
563a377f6b
commit
441c2715bb
3 changed files with 6 additions and 4 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue