1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

Spreadsheet: Have cursor movement keys commit and stop cell editing

Customize the cell editing delegate to stop editing when one of the
various cursor movement keys is hit. This allows you to type into a
cell and then move to an adjacent cell by simply pressing an arrow.

This may not be the best factoring for this feature, but it's pretty
dang cool and we'll see how it evolves over time. :^)
This commit is contained in:
Andreas Kling 2020-08-28 21:24:59 +02:00
parent 057d04d98f
commit c3b2495320
2 changed files with 69 additions and 3 deletions

View file

@ -78,8 +78,13 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet)
m_table_view->set_alternating_row_colors(false);
m_table_view->set_highlight_selected_rows(false);
m_table_view->set_editable(true);
m_table_view->aid_create_editing_delegate = [&](auto&) {
return make<EditingDelegate>(*m_sheet);
m_table_view->aid_create_editing_delegate = [this](auto&) {
auto delegate = make<EditingDelegate>(*m_sheet);
delegate->on_cursor_key_pressed = [this](auto& event) {
m_table_view->stop_editing();
m_table_view->event(event);
};
return delegate;
};
m_table_view->on_selection_change = [&] {