Last active
August 29, 2015 14:21
-
-
Save davidshumway/9827eac41f19b44bd5de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iD.ui.PresetList = function(context) { | |
... | |
function keydown() { | |
// hack to let delete shortcut work when search is autofocused | |
if (search.property('value').length === 0 && | |
(d3.event.keyCode === d3.keybinding.keyCodes['⌫'] || | |
d3.event.keyCode === d3.keybinding.keyCodes['⌦'])) { | |
d3.event.preventDefault(); | |
d3.event.stopPropagation(); | |
iD.operations.Delete([id], context)(); | |
} else if (search.property('value').length === 0 && // How to go about adding the equivalent of this? | |
(d3.event.ctrlKey || d3.event.metaKey) && | |
d3.event.keyCode === d3.keybinding.keyCodes.B) { | |
d3.event.preventDefault(); | |
d3.event.stopPropagation(); | |
} else if (search.property('value').length === 0 && | |
(d3.event.ctrlKey || d3.event.metaKey) && | |
d3.event.keyCode === d3.keybinding.keyCodes.z) { | |
d3.event.preventDefault(); | |
d3.event.stopPropagation(); | |
context.undo(); | |
} else if (!d3.event.ctrlKey && !d3.event.metaKey) { | |
d3.select(this).on('keydown', null); | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following works to bypass autofocus. It adds the keybinding to both the document and the autofocused input field. However, only when the autofocused field (document.getElementsByClassName('preset-search-input')[0]) exists on the page. The input added to the page after first instance of "Select feature type" menu appears, which is after drawing a new entity on the map.