diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-24 21:20:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-24 21:20:54 +0200 |
commit | f86c074be8f83ecbbcaacef47683cddc23e6d936 (patch) | |
tree | f2df15d21b4186c2ee1bf5f3ef42080bbd6c40c1 /Libraries/LibGUI | |
parent | 0f0b37d137207fa838d26045cf275d89d5a8af5e (diff) | |
download | serenity-f86c074be8f83ecbbcaacef47683cddc23e6d936.zip |
LibGUI: Pressing Return in an editable TableView should begin editing
This matches what happens when you double-click on a cell.
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r-- | Libraries/LibGUI/AbstractTableView.cpp | 5 | ||||
-rw-r--r-- | Libraries/LibGUI/AbstractView.cpp | 10 | ||||
-rw-r--r-- | Libraries/LibGUI/AbstractView.h | 1 | ||||
-rw-r--r-- | Libraries/LibGUI/TableView.cpp | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/Libraries/LibGUI/AbstractTableView.cpp b/Libraries/LibGUI/AbstractTableView.cpp index 4e7433bf5f..f312cc7d28 100644 --- a/Libraries/LibGUI/AbstractTableView.cpp +++ b/Libraries/LibGUI/AbstractTableView.cpp @@ -474,10 +474,7 @@ void AbstractTableView::doubleclick_event(MouseEvent& event) if (event.y() < header_height()) return; if (!selection().is_empty()) { - if (is_editable()) - begin_editing(selection().first()); - else - activate_selected(); + activate_or_edit_selected(); } } } diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp index 5fc9425e3b..d6fe8c77a7 100644 --- a/Libraries/LibGUI/AbstractView.cpp +++ b/Libraries/LibGUI/AbstractView.cpp @@ -362,7 +362,15 @@ void AbstractView::doubleclick_event(MouseEvent& event) else if (!m_selection.contains(index)) set_selection(index); - activate_selected(); + activate_or_edit_selected(); +} + +void AbstractView::activate_or_edit_selected() +{ + if (is_editable()) + begin_editing(selection().first()); + else + activate_selected(); } void AbstractView::context_menu_event(ContextMenuEvent& event) diff --git a/Libraries/LibGUI/AbstractView.h b/Libraries/LibGUI/AbstractView.h index 996e843a80..3fb219a721 100644 --- a/Libraries/LibGUI/AbstractView.h +++ b/Libraries/LibGUI/AbstractView.h @@ -100,6 +100,7 @@ protected: void set_hovered_index(const ModelIndex&); void activate(const ModelIndex&); void activate_selected(); + void activate_or_edit_selected(); void update_edit_widget_position(); bool m_editable { false }; diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp index 306a26c42b..b30161e7aa 100644 --- a/Libraries/LibGUI/TableView.cpp +++ b/Libraries/LibGUI/TableView.cpp @@ -159,7 +159,7 @@ void TableView::keydown_event(KeyEvent& event) return; auto& model = *this->model(); if (event.key() == KeyCode::Key_Return) { - activate_selected(); + activate_or_edit_selected(); return; } if (event.key() == KeyCode::Key_Left) { |