diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-16 15:09:29 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-17 01:08:27 +0430 |
commit | 16b4a78072ba69849fed545a058ed8ec61b88d70 (patch) | |
tree | 9cd26e1b6e015f60f882a64fc71b4a9ffce6f39b | |
parent | a01358f015cd8899cde6112bed6224d491829a0f (diff) | |
download | serenity-16b4a78072ba69849fed545a058ed8ec61b88d70.zip |
Spreadsheet: Do not cancel drag-select when moving over a cell corner
Fixes #4277.
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetView.cpp | 16 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetView.h | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index 345be3846d..b0d2322e94 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -83,14 +83,13 @@ void InfinitelyScrollableTableView::mousemove_event(GUI::MouseEvent& event) ScopeGuard sheet_update_enabler { [&] { sheet.enable_updates(); } }; auto holding_left_button = !!(event.buttons() & GUI::MouseButton::Left); - auto rect = content_rect(index); - auto distance = rect.center().absolute_relative_distance_to(event.position()); - if (distance.x() >= rect.width() / 2 - 5 && distance.y() >= rect.height() / 2 - 5) { + if (m_is_dragging_for_copy) { set_override_cursor(Gfx::StandardCursor::Crosshair); m_should_intercept_drag = false; if (holding_left_button) { m_has_committed_to_dragging = true; // Force a drag to happen by moving the mousedown position to the center of the cell. + auto rect = content_rect(index); m_left_mousedown_position = rect.center(); } } else if (!m_should_intercept_drag) { @@ -125,6 +124,17 @@ void InfinitelyScrollableTableView::mousemove_event(GUI::MouseEvent& event) TableView::mousemove_event(event); } +void InfinitelyScrollableTableView::mousedown_event(GUI::MouseEvent& event) +{ + if (this->model()) { + auto index = index_at_event_position(event.position()); + auto rect = content_rect(index); + auto distance = rect.center().absolute_relative_distance_to(event.position()); + m_is_dragging_for_copy = distance.x() >= rect.width() / 2 - 5 && distance.y() >= rect.height() / 2 - 5; + } + AbstractTableView::mousedown_event(event); +} + void InfinitelyScrollableTableView::mouseup_event(GUI::MouseEvent& event) { m_should_intercept_drag = false; diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.h b/Userland/Applications/Spreadsheet/SpreadsheetView.h index a2fa9c91d2..a02589e64a 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.h @@ -73,10 +73,12 @@ private: } virtual void did_scroll() override; virtual void mousemove_event(GUI::MouseEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; virtual void mouseup_event(GUI::MouseEvent&) override; bool m_should_intercept_drag { false }; bool m_has_committed_to_dragging { false }; + bool m_is_dragging_for_copy { false }; GUI::ModelIndex m_starting_selection_index; RefPtr<Core::Timer> m_horizontal_scroll_end_timer; RefPtr<Core::Timer> m_vertical_scroll_end_timer; |