1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:37:36 +00:00

Spreadsheet: Keep value when clicking out of a cell

This commit is contained in:
Brandon Hamilton 2021-05-31 11:01:23 +02:00 committed by Ali Mohammad Pur
parent 73b9cfac1b
commit 6219c3ec3c
2 changed files with 7 additions and 0 deletions

View file

@ -186,6 +186,9 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet)
m_table_view->stop_editing(); m_table_view->stop_editing();
m_table_view->dispatch_event(event); 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; return delegate;
}; };

View file

@ -124,10 +124,14 @@ private:
commit(); commit();
on_cursor_key_pressed(event); on_cursor_key_pressed(event);
}; };
textbox->on_focusout = [this] {
on_cell_focusout(index(), value());
};
return textbox; return textbox;
} }
Function<void(GUI::KeyEvent&)> on_cursor_key_pressed; Function<void(GUI::KeyEvent&)> on_cursor_key_pressed;
Function<void(const GUI::ModelIndex&, const GUI::Variant&)> on_cell_focusout;
private: private:
bool m_has_set_initial_value { false }; bool m_has_set_initial_value { false };