diff options
-rw-r--r-- | Applications/Spreadsheet/SpreadsheetView.cpp | 17 | ||||
-rw-r--r-- | Applications/Spreadsheet/SpreadsheetView.h | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/Applications/Spreadsheet/SpreadsheetView.cpp b/Applications/Spreadsheet/SpreadsheetView.cpp index 7c703e5b4f..4eef78dbe3 100644 --- a/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Applications/Spreadsheet/SpreadsheetView.cpp @@ -84,24 +84,30 @@ void InfinitelyScrollableTableView::mousemove_event(GUI::MouseEvent& event) if (auto model = this->model()) { auto index = index_at_event_position(event.position()); if (!index.is_valid()) - return; + return TableView::mousemove_event(event); 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 || distance.y() > rect.height() / 2) { + if (distance.x() >= rect.width() / 2 - 5 && distance.y() >= rect.height() / 2 - 5) { 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. + m_left_mousedown_position = rect.center(); + } + } else if (!m_should_intercept_drag) { + set_override_cursor(Gfx::StandardCursor::Arrow); if (!holding_left_button) { m_starting_selection_index = index; } else { m_should_intercept_drag = true; m_might_drag = false; } - } else if (!m_should_intercept_drag) { - set_override_cursor(Gfx::StandardCursor::Arrow); } - if (holding_left_button && m_should_intercept_drag) { + if (holding_left_button && m_should_intercept_drag && !m_has_committed_to_dragging) { if (!m_starting_selection_index.is_valid()) m_starting_selection_index = index; @@ -126,6 +132,7 @@ void InfinitelyScrollableTableView::mousemove_event(GUI::MouseEvent& event) void InfinitelyScrollableTableView::mouseup_event(GUI::MouseEvent& event) { m_should_intercept_drag = false; + m_has_committed_to_dragging = false; TableView::mouseup_event(event); } diff --git a/Applications/Spreadsheet/SpreadsheetView.h b/Applications/Spreadsheet/SpreadsheetView.h index c48528938a..ae1fe2e26c 100644 --- a/Applications/Spreadsheet/SpreadsheetView.h +++ b/Applications/Spreadsheet/SpreadsheetView.h @@ -91,6 +91,7 @@ private: virtual void mouseup_event(GUI::MouseEvent&) override; bool m_should_intercept_drag { false }; + bool m_has_committed_to_dragging { false }; GUI::ModelIndex m_starting_selection_index; }; |