From 56656a9c2c6574e92d643e55ae1b518c735d57a3 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 13 Apr 2015 21:13:13 +0000 Subject: [PATCH] small fixes to keymaps --- plugins/c9.ide.keys/editor.js | 12 ++++++++---- plugins/c9.ide.ui/forms.js | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/plugins/c9.ide.keys/editor.js b/plugins/c9.ide.keys/editor.js index 9e802965..9f60eb5c 100644 --- a/plugins/c9.ide.keys/editor.js +++ b/plugins/c9.ide.keys/editor.js @@ -350,9 +350,12 @@ define(function(require, exports, module) { // Add key commands.bindKey(lastKey, commands.commands[name]); + var keys = {}; + keys[commands.platform] = (node.actualKeys || node.keys).split("|"); + var n = { command: node.name, - keys: (node.actualKeys || node.keys).split("|") + keys: keys }; var cmds = settings.getJson("user/key-bindings") || []; @@ -389,6 +392,8 @@ define(function(require, exports, module) { if (!cmd || !cmd.command) return; var keys = cmd.keys; + if (typeof keys == "object" && keys[commands.platform]) + keys = keys[commands.platform]; if (Array.isArray(keys)) keys = keys.join("|"); if (typeof keys == "string") @@ -484,7 +489,7 @@ define(function(require, exports, module) { }).join(",\n"); if (!keys.length) - value += ' // { "command": "nexttab", "keys": ["Ctrl-Tab"] }'; + value += ' // { "command": "nexttab", "keys": { win: "Ctrl-Tab", mac: "Cmd-Tab" } }'; value += "\n]"; @@ -542,8 +547,7 @@ define(function(require, exports, module) { } plugin.form.update([{ - type: "dropdown", - name: "kbmode", + id: "kbmode", items: items }]) } diff --git a/plugins/c9.ide.ui/forms.js b/plugins/c9.ide.ui/forms.js index 354a32cf..20503017 100644 --- a/plugins/c9.ide.ui/forms.js +++ b/plugins/c9.ide.ui/forms.js @@ -21,6 +21,7 @@ define(function(require, exports, module) { var maxwidth = options.colmaxwidth || 300; var widths = options.widths || {}; var skins = options.skins || {}; + var elements = {}; var container, meta = {}; var debug = location.href.indexOf('menus=1') > -1; @@ -388,8 +389,10 @@ define(function(require, exports, module) { }); } - if (options.name) + if (options.name) { node.setAttribute("id", options.name); + elements[node.name] = node; + } ui.insertByIndex(heading.container, node, position, foreign); @@ -400,7 +403,7 @@ define(function(require, exports, module) { function update(items) { items.forEach(function(item) { - var el = plugin.getElement(item.id); + var el = elements[item.id]; switch (el.type) { case "dropdown": var dropdown = el.lastChild; @@ -409,10 +412,17 @@ define(function(require, exports, module) { return ""; }).join(""); - if (data) - dropdown.$model.load("" + data + ""); - if (item.value) - dropdown.setAttribute("value", item.value); + if (data) { + setTimeout(function(){ + dropdown.$model.load("" + data + ""); + + setTimeout(function(){ + var value = item.value || dropdown.value; + dropdown.value = -999; + dropdown.setAttribute("value", value); + }); + }); + } break; default: if ("value" in item)