Skip to content

Commit

Permalink
Fixed an issue where the dragged entry view was not removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Sep 28, 2022
1 parent 7466719 commit d5085fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,19 @@ public DayViewEditController(DayViewBase dayView) {
dayView.addEventFilter(MouseEvent.MOUSE_DRAGGED, this::mouseDragged);

final EventHandler<MouseEvent> mouseReleasedHandler = this::mouseReleased;

// mouse released is very important for us. register with the scene, so we get that in any case.
if (dayView.getScene() != null) {
dayView.addEventFilter(MouseEvent.MOUSE_RELEASED, mouseReleasedHandler);
// dayView.addEventFilter(MouseEvent.MOUSE_EXITED, mouseReleasedHandler);
}

// also register with the scene property. Mostly to remove our event filter if the component gets destroyed.
dayView.sceneProperty().addListener(((observable, oldValue, newValue) -> {
if (oldValue != null) {
oldValue.removeEventFilter(MouseEvent.MOUSE_RELEASED, mouseReleasedHandler);
// oldValue.removeEventFilter(MouseEvent.MOUSE_EXITED, mouseReleasedHandler);
}
if (newValue != null) {
newValue.addEventFilter(MouseEvent.MOUSE_RELEASED, mouseReleasedHandler);
// newValue.addEventFilter(MouseEvent.MOUSE_EXITED, mouseReleasedHandler);
}
}));
dayView.addEventFilter(MouseEvent.MOUSE_MOVED, this::mouseMoved);
Expand Down Expand Up @@ -175,6 +173,8 @@ private void mouseMoved(MouseEvent evt) {
private void mousePressed(MouseEvent evt) {
showEntryDetails = false;

System.out.println("target: " + evt.getTarget());

if (evt.isConsumed() || !evt.getButton().equals(MouseButton.PRIMARY) || evt.getClickCount() > 1) {
return;
}
Expand Down Expand Up @@ -337,9 +337,9 @@ private void mouseReleased(MouseEvent evt) {
DraggedEntry draggedEntry = dayViewBase.getDraggedEntry();

if (draggedEntry != null) {
dayViewBase.setDraggedEntry(null);
if (!draggedEntry.isHidden()) {
entry.setInterval(draggedEntry.getInterval());
dayViewBase.setDraggedEntry(null);
if (dayViewBase.isShowDetailsUponEntryCreation() && showEntryDetails) {
dayViewBase.fireEvent(new RequestEvent(dayViewBase, dayViewBase, entry));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class DayViewSkin<T extends DayView> extends DayViewBaseSkin<T> implement
public DayViewSkin(T view) {
super(view);

entryViewGroup.setMouseTransparent(false);
entryViewGroup.setManaged(false);
entryViewGroup.opacityProperty().bind(Bindings.createDoubleBinding(() -> view.isEditAvailability() && view.getEntryViewAvailabilityEditingBehaviour().equals(AvailabilityEditingEntryBehaviour.OPACITY) ? view.getEntryViewAvailabilityEditingOpacity() : 1,
view.editAvailabilityProperty(), view.entryViewAvailabilityEditingBehaviourProperty(), view.entryViewAvailabilityEditingOpacityProperty()));
Expand Down

0 comments on commit d5085fe

Please sign in to comment.