LibGUI: Move editing key handling up to AbstractView

We want all views to respond to the editing key as long as the relevant
edit trigger is activated.
This commit is contained in:
Andreas Kling 2020-09-24 11:42:11 +02:00
parent ece555b684
commit f52527ef9c
Notes: sideshowbarker 2024-07-19 02:15:22 +09:00
3 changed files with 8 additions and 16 deletions

View file

@ -447,6 +447,14 @@ void AbstractView::set_edit_triggers(unsigned triggers)
void AbstractView::keydown_event(KeyEvent& event)
{
if (event.key() == KeyCode::Key_F2) {
if (is_editable() && edit_triggers() & EditTrigger::EditKeyPressed) {
begin_editing(cursor_index());
event.accept();
return;
}
}
SelectionUpdate selection_update = SelectionUpdate::Set;
if (event.modifiers() == KeyModifier::Mod_Shift) {
selection_update = SelectionUpdate::Shift;

View file

@ -610,14 +610,6 @@ void IconView::keydown_event(KeyEvent& event)
if (!m_visual_row_count || !m_visual_column_count)
return;
if (event.key() == KeyCode::Key_F2) {
if (is_editable() && edit_triggers() & EditTrigger::EditKeyPressed) {
begin_editing(cursor_index());
event.accept();
return;
}
}
if (event.key() == KeyCode::Key_Return) {
activate_selected();
return;

View file

@ -166,14 +166,6 @@ void TableView::keydown_event(KeyEvent& event)
if (!model())
return;
if (event.key() == KeyCode::Key_F2) {
if (is_editable() && edit_triggers() & EditTrigger::EditKeyPressed) {
begin_editing(cursor_index());
event.accept();
return;
}
}
if (event.key() == KeyCode::Key_Return) {
activate(cursor_index());
return;