Support both delete and backspace (fixes #887)

Also show correct key in operation tooltip.
This commit is contained in:
John Firebaugh
2013-03-04 16:51:33 -08:00
parent 053f86f82b
commit 988bfeb767
27 changed files with 25 additions and 33 deletions
+6 -4
View File
@@ -72,10 +72,12 @@ iD.modes.Select = function(context, selection, initial) {
});
operations.forEach(function(operation) {
keybinding.on(operation.key, function() {
if (operation.enabled()) {
operation();
}
operation.keys.forEach(function(key) {
keybinding.on(key, function() {
if (operation.enabled()) {
operation();
}
});
});
});
+1 -1
View File
@@ -17,7 +17,7 @@ iD.operations.Circularize = function(selection, context) {
};
operation.id = "circularize";
operation.key = t('operations.circularize.key');
operation.keys = [t('operations.circularize.key')];
operation.title = t('operations.circularize.title');
operation.description = t('operations.circularize.description');
+1 -1
View File
@@ -24,7 +24,7 @@ iD.operations.Delete = function(selection, context) {
};
operation.id = "delete";
operation.key = t('operations.delete.key');
operation.keys = [iD.ui.cmd('⌫'), iD.ui.cmd('⌦')];
operation.title = t('operations.delete.title');
operation.description = t('operations.delete.description');
+1 -1
View File
@@ -16,7 +16,7 @@ iD.operations.Disconnect = function(selection, context) {
};
operation.id = "disconnect";
operation.key = t('operations.disconnect.key');
operation.keys = [t('operations.disconnect.key')];
operation.title = t('operations.disconnect.title');
operation.description = t('operations.disconnect.description');
+1 -1
View File
@@ -26,7 +26,7 @@ iD.operations.Merge = function(selection, context) {
};
operation.id = "merge";
operation.key = t('operations.merge.key');
operation.keys = [t('operations.merge.key')];
operation.title = t('operations.merge.title');
operation.description = t('operations.merge.description');
+1 -1
View File
@@ -14,7 +14,7 @@ iD.operations.Move = function(selection, context) {
};
operation.id = "move";
operation.key = t('operations.move.key');
operation.keys = [t('operations.move.key')];
operation.title = t('operations.move.title');
operation.description = t('operations.move.description');
+1 -1
View File
@@ -17,7 +17,7 @@ iD.operations.Orthogonalize = function(selection, context) {
};
operation.id = "orthogonalize";
operation.key = t('operations.orthogonalize.key');
operation.keys = [t('operations.orthogonalize.key')];
operation.title = t('operations.orthogonalize.title');
operation.description = t('operations.orthogonalize.description');
+1 -1
View File
@@ -17,7 +17,7 @@ iD.operations.Reverse = function(selection, context) {
};
operation.id = "reverse";
operation.key = t('operations.reverse.key');
operation.keys = [t('operations.reverse.key')];
operation.title = t('operations.reverse.title');
operation.description = t('operations.reverse.description');
+1 -1
View File
@@ -16,7 +16,7 @@ iD.operations.Rotate = function(selection, context) {
};
operation.id = "rotate";
operation.key = t('operations.rotate.key');
operation.keys = [t('operations.rotate.key')];
operation.title = t('operations.rotate.title');
operation.description = t('operations.rotate.description');
+1 -1
View File
@@ -18,7 +18,7 @@ iD.operations.Split = function(selection, context) {
};
operation.id = "split";
operation.key = t('operations.split.key');
operation.keys = [t('operations.split.key')];
operation.title = t('operations.split.title');
operation.description = t('operations.split.description');
+6 -4
View File
@@ -4,15 +4,17 @@ iD.ui.cmd = function(code) {
if (iD.detect().os === 'mac')
return code;
var modifiers = {
var replacements = {
'⌘': 'Ctrl',
'⇧': 'Shift',
'⌥': 'Alt'
'⌥': 'Alt',
'⌫': 'Backspace',
'⌦': 'Delete'
}, keys = [];
for (var i = 0; i < code.length; i++) {
if (code[i] in modifiers) {
keys.push(modifiers[code[i]]);
if (code[i] in replacements) {
keys.push(replacements[code[i]]);
} else {
keys.push(code[i]);
}
+3 -1
View File
@@ -28,7 +28,9 @@ iD.ui.PresetGrid = function(context) {
.attr('type', 'search')
.on('keydown', function() {
// hack to let delete shortcut work when search is autofocused
if (d3.event.keyCode === 46 && search.property('value').length === 0) {
if (search.property('value').length === 0 &&
(d3.event.keyCode === d3.keybinding.keyCodes['⌫'] ||
d3.event.keyCode === d3.keybinding.keyCodes['⌦'])) {
annotation = t('operations.delete.annotation.' + context.geometry(entity.id));
context.perform(
iD.actions.DeleteMultiple([entity.id]),
+1 -1
View File
@@ -84,7 +84,7 @@ iD.ui.RadialMenu = function(operations) {
.append('span')
.style('position', 'static')
.attr('class', 'keyhint')
.text(d.key.replace('⌫', 'Esc'));
.text(d.keys[0]);
}
function mouseout() {
-1
View File
@@ -73,7 +73,6 @@ locale.da = {
'delete': {
title: "Slet",
description: "Fjern dette fra kortet.",
key: "⌦",
annotation: {
point: "Slettede et punkt.",
vertex: "Slettede en node fra en vej.",
-1
View File
@@ -73,7 +73,6 @@ locale.de = {
'delete': {
title: "Löschen",
description: "Lösche dies aus der Karte.",
key: "⌦",
annotation: {
point: "Punkt gelöscht.",
vertex: "Stützpunkt aus einem Weg gelöscht.",
-1
View File
@@ -73,7 +73,6 @@ locale.en = {
'delete': {
title: "Delete",
description: "Remove this from the map.",
key: "⌦",
annotation: {
point: "Deleted a point.",
vertex: "Deleted a node from a way.",
-1
View File
@@ -73,7 +73,6 @@ locale.es = {
'delete': {
title: "Eliminar", //"Delete",
description: "Eliminar del mapa.", //"Remove this from the map.",
key: "⌦",
annotation: {
point: "Punto eliminado.", //"Deleted a point.",
vertex: "Vértice elimnado de la ruta.", //"Deleted a node from a way.",
-1
View File
@@ -73,7 +73,6 @@ locale.fr = {
'delete': {
title: "Supprimer",
description: "Supprime l'élément de la carte.",
key: "⌦",
annotation: {
point: "Supprime un point.",
vertex: "Supprime le noeud d'une ligne.",
-1
View File
@@ -73,7 +73,6 @@ locale.it = {
'delete': {
title: "Cancella",
description: "Cancella questo dalla mappa.",
key: "⌦",
annotation: {
point: "Cancellato un punto.",
vertex: "Cancellato un punto da una linea.",
-1
View File
@@ -73,7 +73,6 @@ locale.ja = {
'delete': {
title: "削除",
description: "この地物をマップから削除",
key: "⌦",
annotation: {
point: "ポイントを削除",
vertex: "ウェイ上のノードを削除",
-1
View File
@@ -73,7 +73,6 @@ locale.lv = {
'delete': {
title: "Dzēst",
description: "Izdzēst no kartes.",
key: "⌦",
annotation: {
point: "Punkts dzēsts.",
vertex: "Mezgls dzests.",
-1
View File
@@ -73,7 +73,6 @@ locale.nl = {
'delete': {
title: "Verwijderen",
description: "Verwijder dit van de kaart.",
key: "⌦",
annotation: {
point: "Punt verwijderd.",
vertex: "Knoop uit een weg verwijderd.",
-1
View File
@@ -73,7 +73,6 @@ locale.pl = {
'delete': {
title: "Usuń",
description: "Usuń to z mapy.",
key: "⌦",
annotation: {
point: "Usunięto punkt.",
vertex: "Usunięto węzeł z drogi.",
-1
View File
@@ -73,7 +73,6 @@ locale.ru = {
'delete': {
title: "Удалить",
description: "Убрать объект с карты.",
key: "⌦",
annotation: {
point: "Удалена точка.",
vertex: "Удалёна точка из линии.",
-1
View File
@@ -73,7 +73,6 @@ locale.tr = {
'delete': {
title: "Sil",
description: "Haritan bunu sil.",
key: "⌦",
annotation: {
point: "Bir nokta silindi.",
vertex: "Yoldan bir nod silindi.",
-1
View File
@@ -73,7 +73,6 @@ locale.uk = {
'delete': {
title: "Вилучити",
description: "Вилучити об’єкт з мапи.",
key: "⌦",
annotation: {
point: "Вилучено точку.",
vertex: "Вилучено точку з лінії.",
-1
View File
@@ -73,7 +73,6 @@ locale.vi = {
'delete': {
title: "Xóa",
description: "Xóa đối tượng này khỏi bản đồ.",
key: "⌦",
annotation: {
point: "Xóa địa điểm.",
vertex: "Xóa nốt khỏi lối.",