diff options
author | Brandon Hamilton <brandon.hamilton@gmail.com> | 2021-05-31 11:01:23 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-05-31 16:57:18 +0430 |
commit | 6219c3ec3cc292df1d790c5175456e81ce7b1242 (patch) | |
tree | 5094169d7beabca508c1e0f32a8809255c50ed26 /Userland/Applications/Spreadsheet | |
parent | 73b9cfac1b4fddd5e8105427ffd8e22d5c2eee51 (diff) | |
download | serenity-6219c3ec3cc292df1d790c5175456e81ce7b1242.zip |
Spreadsheet: Keep value when clicking out of a cell
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetView.cpp | 3 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetView.h | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index 42b57cbf3a..345be3846d 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -186,6 +186,9 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) m_table_view->stop_editing(); m_table_view->dispatch_event(event); }; + delegate->on_cell_focusout = [this](auto& index, auto& value) { + m_table_view->model()->set_data(index, value); + }; return delegate; }; diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.h b/Userland/Applications/Spreadsheet/SpreadsheetView.h index 6c2c3710e0..a2fa9c91d2 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.h @@ -124,10 +124,14 @@ private: commit(); on_cursor_key_pressed(event); }; + textbox->on_focusout = [this] { + on_cell_focusout(index(), value()); + }; return textbox; } Function<void(GUI::KeyEvent&)> on_cursor_key_pressed; + Function<void(const GUI::ModelIndex&, const GUI::Variant&)> on_cell_focusout; private: bool m_has_set_initial_value { false }; |