mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
Spreadsheet: Do not cancel drag-select when moving over a cell corner
Fixes #4277.
This commit is contained in:
parent
a01358f015
commit
16b4a78072
2 changed files with 15 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue