From 2b2974c839f10bd103d2c3e06b402b94c8126657 Mon Sep 17 00:00:00 2001 From: Dirk Lemmermann Date: Tue, 27 Sep 2022 14:07:37 +0200 Subject: [PATCH] Fixes #186 Open event with single click --- .../com/calendarfx/view/EntryViewBase.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/CalendarFXView/src/main/java/com/calendarfx/view/EntryViewBase.java b/CalendarFXView/src/main/java/com/calendarfx/view/EntryViewBase.java index 42a5dba2..5c5c77b2 100644 --- a/CalendarFXView/src/main/java/com/calendarfx/view/EntryViewBase.java +++ b/CalendarFXView/src/main/java/com/calendarfx/view/EntryViewBase.java @@ -30,6 +30,7 @@ import javafx.beans.binding.BooleanBinding; import javafx.beans.property.BooleanProperty; import javafx.beans.property.DoubleProperty; +import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyBooleanWrapper; @@ -37,6 +38,7 @@ import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; @@ -130,7 +132,7 @@ protected EntryViewBase(Entry entry) { focusedProperty().addListener(it -> processFocus()); addEventHandler(MouseEvent.MOUSE_CLICKED, evt -> { - if (evt.getButton().equals(PRIMARY) && evt.getClickCount() == 2) { + if (evt.getButton().equals(PRIMARY) && evt.isStillSincePress() && evt.getClickCount() == getDetailsClickCount()) { showDetails(evt, evt.getScreenX(), evt.getScreenY()); } }); @@ -231,6 +233,28 @@ protected EntryViewBase(Entry entry) { layerProperty().addListener(weakLayerListener); } + private final IntegerProperty detailsClickCount = new SimpleIntegerProperty(this, "detailsClickCount", 2); + + public final int getDetailsClickCount() { + return detailsClickCount.get(); + } + + /** + * Determins the click count that is required to trigger the + * "show details" action. + * + * @see DateControl#entryDetailsCallbackProperty() + * + * @return the "show details" click count + */ + public final IntegerProperty detailsClickCountProperty() { + return detailsClickCount; + } + + public final void setDetailsClickCount(int detailsClickCount) { + this.detailsClickCount.set(detailsClickCount); + } + /** * Returns the calendar entry for which the view was created. *