mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Allow delete key without modifier as shortcut for deleting
(closes #3455) Also fixed a minor bug in `iD.uiCmd` that was causing keyboard shortcuts like '⌘⌫' to convert to 'Ctrl+Backspace+' (note extra trailing '+') It affected only the tooltip display, not the key event binding.
This commit is contained in:
@@ -77,7 +77,7 @@ export function operationDelete(selectedIDs, context) {
|
||||
|
||||
|
||||
operation.id = 'delete';
|
||||
operation.keys = [uiCmd('⌘⌫'), uiCmd('⌘⌦')];
|
||||
operation.keys = [uiCmd('⌘⌫'), uiCmd('⌘⌦'), uiCmd('⌦')];
|
||||
operation.title = t('operations.delete.title');
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export function uiCmd(code) {
|
||||
|
||||
for (var i = 0; i < code.length; i++) {
|
||||
if (code[i] in replacements) {
|
||||
result += replacements[code[i]] + '+';
|
||||
result += replacements[code[i]] + (i < code.length - 1 ? '+' : '');
|
||||
} else {
|
||||
result += code[i];
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ describe('iD.uiCmd', function () {
|
||||
it('changes keys to linux versions', function () {
|
||||
ua = 'Linux';
|
||||
iD.Detect(true); // force redetection
|
||||
expect(iD.uiCmd('⌘⌫')).to.eql('Ctrl+Backspace');
|
||||
expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A');
|
||||
expect(iD.uiCmd('⇧A')).to.eql('Shift+A');
|
||||
expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
|
||||
@@ -44,6 +45,7 @@ describe('iD.uiCmd', function () {
|
||||
it('changes keys to win versions', function () {
|
||||
ua = 'Win';
|
||||
iD.Detect(true); // force redetection
|
||||
expect(iD.uiCmd('⌘⌫')).to.eql('Ctrl+Backspace');
|
||||
expect(iD.uiCmd('⌘A')).to.eql('Ctrl+A');
|
||||
expect(iD.uiCmd('⇧A')).to.eql('Shift+A');
|
||||
expect(iD.uiCmd('⌘⇧A')).to.eql('Ctrl+Shift+A');
|
||||
|
||||
Reference in New Issue
Block a user