From 87642aaf2c516a64149a2ae80c441d2b951af7e8 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Tue, 28 Feb 2023 15:49:44 -0700 Subject: [PATCH] Don't deselect the current task if the user clicks somewhere in the map view Signed-off-by: Taylor Smock --- .../gui/layer/MapRouletteClusteredPointLayer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayer.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayer.java index c0b4963..1e5d6f9 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayer.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayer.java @@ -35,6 +35,8 @@ import org.openstreetmap.josm.data.osm.Relation; import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; +import org.openstreetmap.josm.data.preferences.CachingProperty; +import org.openstreetmap.josm.data.preferences.IntegerProperty; import org.openstreetmap.josm.data.preferences.NamedColorProperty; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.MapView; @@ -62,6 +64,10 @@ * A layer for showing task locations */ public class MapRouletteClusteredPointLayer extends Layer implements MouseListener { + /** The number of clicks for deselection */ + private static final CachingProperty DESELECT_CLICK_COUNT = new IntegerProperty( + "maproulette.task.deselect.mouse.click.count", 3).cached(); + /** * The style source, mostly used for preferences */ @@ -292,7 +298,11 @@ public void mouseClicked(MouseEvent e) { } } } - this.setSelected(add); + if (add.isEmpty() && e.getClickCount() >= DESELECT_CLICK_COUNT.get()) { + this.setSelected(Collections.emptyList()); + } else if (!add.isEmpty()) { + this.setSelected(add); + } this.invalidate(); }