From c9544cc506ec812c8703c5bd859d1abead0c7c53 Mon Sep 17 00:00:00 2001 From: Dirk Lemmermann Date: Mon, 12 Sep 2022 17:27:56 +0200 Subject: [PATCH] Ensuring infinite scrolling does not collide with newly added lasso support. --- .../view/DayViewEditController.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/CalendarFXView/src/main/java/impl/com/calendarfx/view/DayViewEditController.java b/CalendarFXView/src/main/java/impl/com/calendarfx/view/DayViewEditController.java index 4d7aef4f..2b362145 100644 --- a/CalendarFXView/src/main/java/impl/com/calendarfx/view/DayViewEditController.java +++ b/CalendarFXView/src/main/java/impl/com/calendarfx/view/DayViewEditController.java @@ -170,9 +170,11 @@ private void mousePressed(MouseEvent evt) { return; } - VirtualGrid availabilityGrid = dayViewBase.getAvailabilityGrid(); - setLassoStart(grid(dayViewBase.getInstantAt(evt), availabilityGrid)); - setLassoEnd(grid(dayViewBase.getInstantAt(evt), availabilityGrid).plus(availabilityGrid.getAmount(), availabilityGrid.getUnit())); + if (!dayViewBase.isScrollingEnabled()) { + VirtualGrid availabilityGrid = dayViewBase.getAvailabilityGrid(); + setLassoStart(grid(dayViewBase.getInstantAt(evt), availabilityGrid)); + setLassoEnd(grid(dayViewBase.getInstantAt(evt), availabilityGrid).plus(availabilityGrid.getAmount(), availabilityGrid.getUnit())); + } dragMode = null; handle = null; @@ -186,7 +188,7 @@ private void mousePressed(MouseEvent evt) { LOGGER.finer("mouse event y-coordinate:" + evt.getY()); LOGGER.finer("time: " + dayViewBase.getZonedDateTimeAt(evt.getX(), evt.getY(), dayViewBase.getZoneId())); - if (evt.getTarget() instanceof DayView) { + if (!dayViewBase.isScrollingEnabled() && evt.getTarget() instanceof DayView) { Optional calendar = dayViewBase.getCalendarAt(evt.getX(), evt.getY()); Instant instantAt = dayViewBase.getInstantAt(evt); ZonedDateTime time = ZonedDateTime.ofInstant(instantAt, dayViewBase.getZoneId()); @@ -274,14 +276,17 @@ private void mouseReleased(MouseEvent evt) { return; } - getOnLassoFinished().accept(getLassoStart(), getLassoEnd()); + if (!dayViewBase.isScrollingEnabled()) { + getOnLassoFinished().accept(getLassoStart(), getLassoEnd()); - setLassoStart(null); - setLassoEnd(null); + setLassoStart(null); + setLassoEnd(null); + } if (!evt.getButton().equals(MouseButton.PRIMARY) || dragMode == null || !dragging) { return; } + dragging = false; Calendar calendar = entry.getCalendar(); @@ -311,7 +316,9 @@ private void mouseReleased(MouseEvent evt) { } private void mouseDragged(MouseEvent evt) { - setLassoEnd(grid(dayViewBase.getInstantAt(evt), dayViewBase.getAvailabilityGrid())); + if (!dayViewBase.isScrollingEnabled()) { + setLassoEnd(grid(dayViewBase.getInstantAt(evt), dayViewBase.getAvailabilityGrid())); + } if (!evt.getButton().equals(MouseButton.PRIMARY) || dragMode == null || !dragging) { return; @@ -322,12 +329,6 @@ private void mouseDragged(MouseEvent evt) { return; } -// if (dayViewBase.getDraggedEntry() == null || dayEntryView.getParent() == null) { -// // we might see "mouse dragged" events close before "mouse pressed". in this case, our drag/dro handling -// // has not been fully initialized yet. -// return; -// } - switch (dragMode) { case START_TIME: switch (handle) {