-
Notifications
You must be signed in to change notification settings - Fork 27
Right click menus #82
base: master
Are you sure you want to change the base?
Changes from all commits
3226b14
89287f7
74f4455
bb2e396
dcca6cc
916eabf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
var reload = function(item, focusedWindow) { | ||
if (focusedWindow) { | ||
focusedWindow.webContents.reload(); | ||
} | ||
}; | ||
|
||
var comment = function(item, focusedWindow) { | ||
var selection = document.getSelection(); | ||
if (selection.toString().length > 0) { | ||
var textbox = document.getElementById("post_textbox"); | ||
textbox.value = "> " + selection; | ||
textbox.focus(); | ||
} | ||
}; | ||
|
||
var changeTemplateForOSx = function(obj){ | ||
//OSx uses the 'selector' key whereas Windows/Linux uses 'role' | ||
for (var i=0; i < obj.length; i++) { | ||
if (obj[i].role) { | ||
obj[i].selector = obj[i].role; | ||
delete obj[i].role; | ||
} | ||
} | ||
return obj; | ||
}; | ||
|
||
var template = [ | ||
{ | ||
label: 'Undo', | ||
accelerator: 'CmdOrCtrl+Z', | ||
role: 'undo:' | ||
}, | ||
{ | ||
label: 'Redo', | ||
accelerator: 'Shift+CmdOrCtrl+Z', | ||
role: 'redo:' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Cut', | ||
accelerator: 'CmdOrCtrl+X', | ||
role: 'cut:' | ||
}, | ||
{ | ||
label: 'Copy', | ||
accelerator: 'CmdOrCtrl+C', | ||
role: 'copy:' | ||
}, | ||
{ | ||
label: 'Paste', | ||
accelerator: 'CmdOrCtrl+V', | ||
role: 'paste:' | ||
}, | ||
{ | ||
label: 'Select All', | ||
accelerator: 'CmdOrCtrl+A', | ||
role: 'selectAll:' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Reload', | ||
accelerator: 'CmdOrCtrl+R', | ||
click: reload | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Comment', | ||
accelerator: 'Shift+CmdOrCtrl+C', | ||
click: comment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this one on the context menu, and I'm not seeing any functionality out of it. What is it supposed to do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Obvious question but did you pull the latest? I just added this commit late yesterday. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pulled it at 11pm. :-) I'll figure it out. Probably just a user error.
|
||
} | ||
]; | ||
|
||
if (process.platform === 'darwin') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you change this condition so it is false you'll see that the use of |
||
template = changeTemplateForOSx(template); | ||
} | ||
|
||
module.exports = template |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var remote = require('remote'); | ||
var Menu = remote.require('menu'); | ||
var template = require("./context-menu-template.js"); | ||
|
||
var menu = {}; | ||
|
||
menu.load = function(){ | ||
var contextMenu = Menu.buildFromTemplate(template); | ||
document.addEventListener('contextmenu', function (e) { | ||
e.preventDefault(); | ||
contextMenu.popup(remote.getCurrentWindow()); | ||
}, false); | ||
}; | ||
|
||
module.exports = menu; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require("./mattermost-observer.js"); | ||
require("./context-menu.js").load(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, they both say
CmdOrCtrl+C
...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is that OSx uses the
selector
property and non-OSx uses therole
property on the menu item.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried
role
for OSx and the items were grayed out.