Skip to content

Commit

Permalink
Merge pull request mapbox#354 from mapbox/disable-keybindings
Browse files Browse the repository at this point in the history
disable keybinding if corresponding control is disabled, closes mapbox#265
  • Loading branch information
samanpwbb authored Jun 13, 2016
2 parents d66773f + c1ab182 commit cc9b454
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ module.exports = function(ctx) {
var isKeyModeValid = (code) => !(code === 8 || (code >= 48 && code <= 57));

events.keydown = function(event) {
if (event.keyCode === 8) {
if (event.keyCode === 8 && ctx.options.controls.trash) {
event.preventDefault();
api.fire('trash');
}
else if (isKeyModeValid(event.keyCode)) {
currentMode.keydown(event);
}
else if (event.keyCode === 49) {
else if (event.keyCode === 49 && ctx.options.controls.point) {
ctx.api.changeMode('draw_point');
}
else if (event.keyCode === 50) {
else if (event.keyCode === 50 && ctx.options.controls.line_string) {
ctx.api.changeMode('draw_line_string');
}
else if (event.keyCode === 51) {
else if (event.keyCode === 51 && ctx.options.controls.polygon) {
ctx.api.changeMode('draw_polygon');
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = function(ctx) {
}
}

if (controls.line_string) {
if (controls[types.LINE]) {
buttons[types.LINE] = createButton(controlGroup, {
className: `${controlClass} mapbox-gl-draw_line`,
title: `LineString tool ${ctx.options.keybindings && '(l)'}`,
Expand Down

0 comments on commit cc9b454

Please sign in to comment.