From 419b1ec34872f3a255139f91838d30d9a88bd281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20H=C3=A5kansson?= Date: Wed, 28 May 2014 21:50:42 +0200 Subject: [PATCH] Submenus now work with old context menu structure --- src/context-menu-manager.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/context-menu-manager.coffee b/src/context-menu-manager.coffee index f22ee92ea..0ce631248 100644 --- a/src/context-menu-manager.coffee +++ b/src/context-menu-manager.coffee @@ -35,9 +35,15 @@ class ContextMenuManager for selector, items of object for label, commandOrSubmenu of items if typeof commandOrSubmenu is 'object' - @addBySelector(selector, commandOrSubmenu, {devMode}) + submenu = []; + for submenuLabel, command of commandOrSubmenu + submenu.push({label: submenuLabel, command: command}) + @addBySelector(selector, {label: label, submenu: submenu}, {devMode}) else - @addBySelector(selector, {label, commandOrSubmenu}, {devMode}) + if label is commandOrSubmenu is '-' + @addBySelector(selector, {type: 'separator'}, {devMode}) + else + @addBySelector(selector, {label: label, command: commandOrSubmenu}, {devMode}) # Registers a command to be displayed when the relevant item is right # clicked.