1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

Spreadsheet: Do not cancel drag-select when moving over a cell corner

Fixes #4277.
This commit is contained in:
Ali Mohammad Pur 2021-06-16 15:09:29 +04:30 committed by Ali Mohammad Pur
parent a01358f015
commit 16b4a78072
2 changed files with 15 additions and 3 deletions

View file

@ -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;