Skip to content

Commit

Permalink
Add macOS context menu position
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Mar 16, 2019
1 parent d6adaa2 commit 8726af8
Showing 1 changed file with 55 additions and 5 deletions.
60 changes: 55 additions & 5 deletions src/browser/menu.js
Expand Up @@ -329,13 +329,20 @@ class ContextMenu extends Menu {
}

show({ scope, event }, window) {
return new Promise((resolve, reject) => {
return new Promise((callback, reject) => {
let settings = ContextMenu.scopes[scope]

try {
this.build(
this.prepare(this.template, ContextMenu.scopes[scope]),
let menu = this.build(
this.prepare(this.template, settings),
window,
event)

menu.popup({
window,
event
).popup({ window, callback: resolve })
callback,
positioningItem: settings.position
})

} catch (error) {
warn(`failed to show context-menu: ${error.message}`, {
Expand All @@ -352,29 +359,72 @@ class ContextMenu extends Menu {
const { scopes } = ContextMenu

scopes.sidebar = [...scopes.global, 'project', 'lists', 'tags']
scopes.sidebar.position = 2

scopes.lists = [...scopes.sidebar]
scopes.lists.position = 5

scopes.list = [...scopes.global, 'project', 'lists', 'list', 'tags']
scopes.list.position = 5

scopes.tags = [...scopes.sidebar]
scopes.tags.position = 7

scopes.tag = [...scopes.sidebar, 'tag']
scopes.tag.position = 7

scopes.items = [...scopes.global, 'items']
scopes.items.position = 2

scopes.item = [...scopes.items, 'item', 'item-rotate']
scopes.item.position = 2

scopes.trash = [...scopes.sidebar, 'trash']
scopes.trash.position = 10

scopes.photo = [...scopes.global, 'photo', 'photo-rotate']
scopes.photo.position = 2

scopes.selection = [
...scopes.global, 'photo', 'selection', 'selection-rotate'
]
scopes.selection.position = 8

scopes.note = [...scopes.global, 'note']
scopes.note.position = 2

scopes['metadata-list'] = [...scopes.global, 'metadata-list']
scopes['metadata-list'].position = 2

scopes['metadata-field'] = [...scopes['metadata-list'], 'metadata-field']
scopes['metadata-field'].position = 2

scopes['item-bulk'] = [...scopes.items, 'item-bulk', 'item-rotate']
scopes['item-bulk'].position = 2

scopes['item-list'] = [...scopes.items, 'item-list', 'item', 'item-rotate']
scopes['item-list'].position = 2

scopes['item-bulk-list'] = [...scopes.items, 'item-bulk-list', 'item-bulk']
scopes['item-bulk-list'].position = 2

scopes['item-deleted'] = [...scopes.global, 'item-deleted']
scopes['item-deleted'].position = 2

scopes['item-bulk-deleted'] = [...scopes.global, 'item-bulk-deleted']
scopes['item-bulk-deleted'].position = 2

scopes['item-tag'] = [...scopes.global, 'item-tag']
scopes['item-tag'].position = 2

scopes['item-view'] = [...scopes.global, 'item-view']
scopes['item-view'].position = 2

scopes.notepad = [...scopes['item-view'], 'notepad']
scopes.notepad.position = 2

scopes.esper = [...scopes['item-view']]
scopes.esper.position = 2
}

module.exports = {
Expand Down

0 comments on commit 8726af8

Please sign in to comment.