From 6219c3ec3cc292df1d790c5175456e81ce7b1242 Mon Sep 17 00:00:00 2001 From: Brandon Hamilton Date: Mon, 31 May 2021 11:01:23 +0200 Subject: Spreadsheet: Keep value when clicking out of a cell --- Userland/Applications/Spreadsheet/SpreadsheetView.cpp | 3 +++ Userland/Applications/Spreadsheet/SpreadsheetView.h | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'Userland/Applications/Spreadsheet') 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 on_cursor_key_pressed; + Function on_cell_focusout; private: bool m_has_set_initial_value { false }; -- cgit v1.2.3