mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Context menus can now handle different types and commands, as well as submenus
This commit is contained in:
@@ -19,4 +19,6 @@ class ContextMenu
|
||||
do (item) =>
|
||||
item.click = =>
|
||||
global.atomApplication.sendCommandToWindow(item.command, @atomWindow, item.commandOptions)
|
||||
else if item.submenu
|
||||
@createClickHandlers(item.submenu)
|
||||
item
|
||||
|
||||
@@ -34,7 +34,10 @@ class ContextMenuManager
|
||||
add: (name, object, {devMode}={}) ->
|
||||
for selector, items of object
|
||||
for label, command of items
|
||||
@addBySelector(selector, {label, command}, {devMode})
|
||||
if (typeof command == 'object')
|
||||
@addBySelector(selector, command, {devMode})
|
||||
else
|
||||
@addBySelector(selector, {label, command}, {devMode})
|
||||
|
||||
# Registers a command to be displayed when the relevant item is right
|
||||
# clicked.
|
||||
@@ -49,6 +52,8 @@ class ContextMenuManager
|
||||
definitions = if devMode then @devModeDefinitions else @definitions
|
||||
(definitions[selector] ?= []).push(definition)
|
||||
|
||||
|
||||
|
||||
# Returns definitions which match the element and devMode.
|
||||
definitionsForElement: (element, {devMode}={}) ->
|
||||
definitions = if devMode then @devModeDefinitions else @definitions
|
||||
|
||||
Reference in New Issue
Block a user