Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cut/copy/paste, multiple selection, and Edit menu #59

Closed
wants to merge 9 commits into from
7 changes: 7 additions & 0 deletions locales/en-US/menus-en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"save": "&Save Project",
"saveas": "Save Project &as…"
},
"edit" : {
"cut": "Cut",
"copy": "&Copy",
"paste": "Paste",
"delete": "Delete",
"selectall": "Select &All"
},
"view" : {
"settings": "Advanced Settings"
},
Expand Down
25 changes: 25 additions & 0 deletions menus/menu-darwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,31 @@ module.exports = function applyTemplate() {
}
]
},
{
label: 'Edit ', // space prevents OS X from adding Dictation/Emoji menu items
submenu: [
{
key: 'edit.cut',
accelerator: 'Command+X'
},
{
key: 'edit.copy',
accelerator: 'Command+C'
},
{
key: 'edit.paste',
accelerator: 'Command+V'
},
{
key: 'edit.delete',
accelerator: 'Backspace'
},
{
key: 'edit.selectall',
accelerator: 'Command+A'
}
]
},
{
label: 'View',
submenu: [
Expand Down
25 changes: 25 additions & 0 deletions menus/menu-win32.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@ module.exports = function applyTemplate() {
}
]
},
{
label: 'Edit',
submenu: [
{
key: 'edit.cut',
accelerator: 'Control+X'
},
{
key: 'edit.copy',
accelerator: 'Control+C'
},
{
key: 'edit.paste',
accelerator: 'Control+V'
},
{
key: 'edit.delete',
accelerator: 'Delete'
},
{
key: 'edit.selectall',
accelerator: 'Control+A'
}
]
},
{
label: 'View',
submenu: [
Expand Down
55 changes: 49 additions & 6 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ function activateToolItem(item) {
paper.view.update();
}

function switchToSelectTool() {
var selectTool = _.findWhere(paper.tools, { key: 'select'});
if (selectTool) {
selectTool.activate();
activateToolItem($("#tool-select"));
}
}

// Build the elements for the colorpicker non-tool item
function buildColorPicker() {
var $picker = $('<div>').attr('id', 'picker');
Expand Down Expand Up @@ -288,17 +296,17 @@ function selectColor(index) {

// Change selected path's color
if (paper.selectRect) {
if (paper.selectRect.ppath) {
if (paper.selectRect.ppath.data.fill === true) {
paper.selectRect.ppath.fillColor = paper.pancakeShades[index];
_.each(paper.selectRect.paths, function (selectedPath) {
if (selectedPath.data.fill === true) {
selectedPath.fillColor = paper.pancakeShades[index];
} else {
paper.selectRect.ppath.strokeColor = paper.pancakeShades[index];
selectedPath.strokeColor = paper.pancakeShades[index];
}

paper.selectRect.ppath.data.color = index;
selectedPath.data.color = index;
paper.view.update();
currentFile.changed = true;
}
});
}
}

Expand Down Expand Up @@ -417,6 +425,41 @@ function bindControls() {
paper.newPBP();
});
break;
case 'edit.cut':
if (paper.tool.key === 'select') {
paper.tool.copySelectionToBuffer();
paper.tool.deleteSelection();
currentFile.changed = true;
paper.view.update();
}
break;
case 'edit.copy':
if (paper.tool.key === 'select') {
paper.tool.copySelectionToBuffer();
}
break;
case 'edit.paste':
if (paper.tool.key !== 'select') {
switchToSelectTool();
}
paper.tool.pasteFromBuffer();
currentFile.changed = true;
paper.view.update();
break;
case 'edit.delete':
if (paper.tool.key === 'select') {
paper.tool.deleteSelection();
currentFile.changed = true;
paper.view.update();
}
break;
case 'edit.selectall':
if (paper.tool.key !== 'select') {
switchToSelectTool();
}
paper.tool.selectAll();
paper.view.update();
break;
case 'view.settings':
toggleOverlay(true, function(){
$('#settings').fadeIn('slow');
Expand Down
Loading