diff --git a/plugins/draw-tools.user.js b/plugins/draw-tools.user.js index 539e8757..0a11a233 100644 --- a/plugins/draw-tools.user.js +++ b/plugins/draw-tools.user.js @@ -165,7 +165,37 @@ window.plugin.drawTools.addDrawControl = function() { window.plugin.drawTools.drawControl = drawControl; map.addControl(drawControl); -// plugin.drawTools.addCustomButtons(); + //plugin.drawTools.addCustomButtons(); + + window.plugin.drawTools.setAccessKeys(); + for (var toolbarId in drawControl._toolbars) { + if (drawControl._toolbars[toolbarId] instanceof L.Toolbar) { + drawControl._toolbars[toolbarId].on('enable', function() { + setTimeout(window.plugin.drawTools.setAccessKeys, 10); + }); + } + } +} + +window.plugin.drawTools.setAccessKeys = function() { + console.log("accesskeys",arguments[0]); + // there is no API to add accesskeys, so have to dig in the DOM + // must be same order as in markup. Note that each toolbar has a container for save/cancel + var accessKeys = [ + 'l', 'p', 'o', 'm', // line, polygon, circle, marker + 'a', // cancel (_abort) + 'e', 'd', // edit, delete + 's', 'a', // save, cancel + ]; + var buttons = window.plugin.drawTools.drawControl._container.getElementsByTagName('a'); + for(var i=0;i