From bf91c1792bea99e6f0599a894c5e064dd2d2555a Mon Sep 17 00:00:00 2001
From: tarang
Date: Wed, 29 Apr 2015 15:12:51 +0530
Subject: [PATCH] added altclick select to selectfeatures example
---
examples/select-features.html | 3 ++-
examples/select-features.js | 9 +++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/examples/select-features.html b/examples/select-features.html
index 1eeae515eb..9f0b854e0f 100644
--- a/examples/select-features.html
+++ b/examples/select-features.html
@@ -3,7 +3,7 @@ template: example.html
title: Select features example
shortdesc: Example of using the Select interaction.
docs: >
- Choose between Single-click, Click and Hover as the event type for selection in the combobox below. When using Single-click or Click you can hold do Shift key to toggle the feature in the selection.
+ Choose between Single-click, Click, Hover and Alt+Click as the event type for selection in the combobox below. When using Single-click or Click you can hold do Shift key to toggle the feature in the selection.
Note: when Single-click is used double-clicks won't select features. This in contrast to Click, where a double-click will both select the feature and zoom the map (because of the DoubleClickZoom interaction). Note that Single-click is less responsive than Click because of the delay it uses to detect double-clicks.
In this example, a listener is registered for the Select interaction's select event in order to update the selection status below.
diff --git a/examples/select-features.js b/examples/select-features.js
index c59d0893d2..1e4e5b1f71 100644
--- a/examples/select-features.js
+++ b/examples/select-features.js
@@ -43,6 +43,13 @@ var selectPointerMove = new ol.interaction.Select({
condition: ol.events.condition.pointerMove
});
+var selectAltClick = new ol.interaction.Select({
+ condition: function(mapBrowserEvent) {
+ return ol.events.condition.click(mapBrowserEvent) &&
+ ol.events.condition.altKeyOnly(mapBrowserEvent);
+ }
+});
+
var selectElement = document.getElementById('type');
var changeInteraction = function() {
@@ -56,6 +63,8 @@ var changeInteraction = function() {
select = selectClick;
} else if (value == 'pointermove') {
select = selectPointerMove;
+ } else if (value == 'altclick') {
+ select = selectAltClick;
} else {
select = null;
}