1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 02:13:56 +09:00

LibGUI: Pressing Return in an editable TableView should begin editing

This matches what happens when you double-click on a cell.
This commit is contained in:
Andreas Kling 2020-08-24 21:20:54 +02:00
parent 0f0b37d137
commit f86c074be8
Notes: sideshowbarker 2024-07-19 03:12:05 +09:00
4 changed files with 12 additions and 6 deletions

View file

@ -474,10 +474,7 @@ void AbstractTableView::doubleclick_event(MouseEvent& event)
if (event.y() < header_height()) if (event.y() < header_height())
return; return;
if (!selection().is_empty()) { if (!selection().is_empty()) {
if (is_editable()) activate_or_edit_selected();
begin_editing(selection().first());
else
activate_selected();
} }
} }
} }

View file

@ -362,7 +362,15 @@ void AbstractView::doubleclick_event(MouseEvent& event)
else if (!m_selection.contains(index)) else if (!m_selection.contains(index))
set_selection(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) void AbstractView::context_menu_event(ContextMenuEvent& event)

View file

@ -100,6 +100,7 @@ protected:
void set_hovered_index(const ModelIndex&); void set_hovered_index(const ModelIndex&);
void activate(const ModelIndex&); void activate(const ModelIndex&);
void activate_selected(); void activate_selected();
void activate_or_edit_selected();
void update_edit_widget_position(); void update_edit_widget_position();
bool m_editable { false }; bool m_editable { false };

View file

@ -159,7 +159,7 @@ void TableView::keydown_event(KeyEvent& event)
return; return;
auto& model = *this->model(); auto& model = *this->model();
if (event.key() == KeyCode::Key_Return) { if (event.key() == KeyCode::Key_Return) {
activate_selected(); activate_or_edit_selected();
return; return;
} }
if (event.key() == KeyCode::Key_Left) { if (event.key() == KeyCode::Key_Left) {