Skip to content

Commit 54b1042

Browse files
markjd84cmcaine
authored andcommitted
Expose ctrl, shift, alt and meta on click events
1 parent 9841cde commit 54b1042

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

inst/htmlwidgets/leaflet.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,13 @@ _htmlwidgets2.default.widget({
655655
_shiny2.default.onInputChange(map.id + "_click", {
656656
lat: e.latlng.lat,
657657
lng: e.latlng.lng,
658-
".nonce": Math.random() // Force reactivity if lat/lng hasn't changed
658+
".nonce": Math.random(), // Force reactivity if lat/lng hasn't changed
659+
modifiers: {
660+
alt: e.originalEvent.altKey,
661+
ctrl: e.originalEvent.ctrlKey,
662+
meta: e.originalEvent.metaKey,
663+
shift: e.originalEvent.shiftKey
664+
}
659665
});
660666
});
661667

@@ -1352,7 +1358,12 @@ function mouseHandler(mapId, layerId, group, eventName, extraInfo) {
13521358
}
13531359
var eventInfo = _jquery2.default.extend({
13541360
id: layerId,
1355-
".nonce": Math.random() // force reactivity
1361+
".nonce": Math.random(), // force reactivity
1362+
modifiers: {
1363+
ctrl: e.originalEvent.ctrlKey,
1364+
shift: e.originalEvent.shiftKey,
1365+
alt: e.originalEvent.altKey
1366+
}
13561367
}, group !== null ? { group: group } : null, latLng, extraInfo);
13571368

13581369
_shiny2.default.onInputChange(mapId + "_" + eventName, eventInfo);

javascript/src/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ HTMLWidgets.widget({
140140
Shiny.onInputChange(map.id + "_click", {
141141
lat: e.latlng.lat,
142142
lng: e.latlng.lng,
143-
".nonce": Math.random() // Force reactivity if lat/lng hasn't changed
143+
".nonce": Math.random(), // Force reactivity if lat/lng hasn't changed
144+
modifiers: {
145+
alt: e.originalEvent.altKey,
146+
ctrl: e.originalEvent.ctrlKey,
147+
meta: e.originalEvent.metaKey,
148+
shift: e.originalEvent.shiftKey
149+
}
144150
});
145151
});
146152

javascript/src/methods.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ function mouseHandler(mapId, layerId, group, eventName, extraInfo) {
8181
let eventInfo = $.extend(
8282
{
8383
id: layerId,
84-
".nonce": Math.random() // force reactivity
84+
".nonce": Math.random(), // force reactivity
85+
modifiers: {
86+
ctrl: e.originalEvent.ctrlKey,
87+
shift: e.originalEvent.shiftKey,
88+
alt: e.originalEvent.altKey
89+
}
8590
},
8691
group !== null ? {group: group} : null,
8792
latLng,

0 commit comments

Comments
 (0)