summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2022-02-27 11:37:28 +0100
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-03-03 22:19:50 +0330
commitf384aff5104d596ce9a600db22b9a595e96e1721 (patch)
treefdc5d5d1d4da3ff7880b290798976218fd407894 /Userland/Applications
parentdc65543fa9741316b96c96b6bc8da3205b597850 (diff)
downloadserenity-f384aff5104d596ce9a600db22b9a595e96e1721.zip
Spreadsheet: Move deselection instructions to on_selection_dropped
The previous code never executed, as SpreadsheetView splits selection events into `on_selection_changed` and `on_selection_dropped` depending on whether there is any selection.
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index e65fa4fa30..746ff3b2b3 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -272,18 +272,8 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
// How did this even happen?
VERIFY(sheet_ptr);
auto& sheet = *sheet_ptr;
- if (selection.is_empty()) {
- m_current_cell_label->set_enabled(false);
- m_current_cell_label->set_text({});
- m_cell_value_editor->on_change = nullptr;
- m_cell_value_editor->on_focusin = nullptr;
- m_cell_value_editor->on_focusout = nullptr;
- m_cell_value_editor->set_text("");
- m_cell_value_editor->set_enabled(false);
- m_cut_action->set_enabled(false);
- m_copy_action->set_enabled(false);
- return;
- }
+
+ VERIFY(!selection.is_empty());
if (selection.size() == 1) {
auto& position = selection.first();
@@ -345,11 +335,18 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(&first_cell);
};
m_selected_view->on_selection_dropped = [&]() {
+ m_current_cell_label->set_enabled(false);
+ m_current_cell_label->set_text({});
+ m_cell_value_editor->on_change = nullptr;
+ m_cell_value_editor->on_focusin = nullptr;
+ m_cell_value_editor->on_focusout = nullptr;
+ m_cell_value_editor->set_text({});
m_cell_value_editor->set_enabled(false);
+
+ m_cut_action->set_enabled(false);
+ m_copy_action->set_enabled(false);
+
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(nullptr);
- m_cell_value_editor->set_text("");
- m_current_cell_label->set_enabled(false);
- m_current_cell_label->set_text("");
};
};