Skip to content

Commit

Permalink
Merge pull request #860 from wonderunit/811-menu-commands
Browse files Browse the repository at this point in the history
Menu commands (undo, redo, copy, paste)
  • Loading branch information
audionerd authored Oct 30, 2017
2 parents 4ee9aa9 + 5a17b70 commit 996cc8d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ AppMenu.Edit = () => ({
{
label: 'Undo',
accelerator: 'CmdOrCtrl+Z',
role: 'undo'
click (item, focusedWindow, event) {
ipcRenderer.send('undo')
}
},
{
label: 'Redo',
accelerator: 'Shift+CmdOrCtrl+Z',
role: 'redo'
click (item, focusedWindow, event) {
ipcRenderer.send('redo')
}
},
{
type: 'separator'
Expand All @@ -158,12 +162,16 @@ AppMenu.Edit = () => ({
{
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
role: 'copy'
click (item, focusedWindow, event) {
ipcRenderer.send('copy')
}
},
{
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
role: 'paste'
click (item, focusedWindow, event) {
ipcRenderer.send('paste')
}
},
/*
{
Expand Down
28 changes: 24 additions & 4 deletions src/js/window/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -3576,9 +3576,11 @@ ipcRenderer.on('nextScene', (event, args)=>{
// tools

ipcRenderer.on('undo', (e, arg) => {
if (storyboarderSketchPane.preventIfLocked()) return
if (textInputMode) {
remote.getCurrentWebContents().undo()
} else {
if (storyboarderSketchPane.preventIfLocked()) return

if (!textInputMode) {
if (undoStack.getCanUndo()) {
undoStack.undo()
sfx.rollover()
Expand All @@ -3590,9 +3592,11 @@ ipcRenderer.on('undo', (e, arg) => {
})

ipcRenderer.on('redo', (e, arg) => {
if (storyboarderSketchPane.preventIfLocked()) return
if (textInputMode) {
remote.getCurrentWebContents().redo()
} else {
if (storyboarderSketchPane.preventIfLocked()) return

if (!textInputMode) {
if (undoStack.getCanRedo()) {
undoStack.redo()
sfx.rollover()
Expand All @@ -3603,6 +3607,22 @@ ipcRenderer.on('redo', (e, arg) => {
}
})

ipcRenderer.on('copy', () => {
if (textInputMode) {
remote.getCurrentWebContents().copy()
} else {
copyBoards()
}
})

ipcRenderer.on('paste', () => {
if (textInputMode) {
remote.getCurrentWebContents().paste()
} else {
pasteBoards()
}
})

// import image from mobile server
let importImage = imageDataURL => {
// TODO: undo
Expand Down

0 comments on commit 996cc8d

Please sign in to comment.