Created
November 12, 2011 16:31
-
-
Save joemccann/1360777 to your computer and use it in GitHub Desktop.
Ace Editor Add Command Fail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bindKeyboard(){ | |
// CMD+s TO SAVE DOC | |
var command = { | |
name: "save", | |
bindKey: { | |
mac: "Command-S", | |
win: "Ctrl-S" | |
}, | |
exec: function(){ | |
saveFile() // this function is defined elsewhere, but available in outer scope. | |
} | |
} | |
// Tried this first: | |
editor.commands.addCommand(command) | |
// But this fails as editor.commands is undefined | |
// Then I tried this: | |
var cm = new CommandManager("mac", [command]); | |
// But this fails because CommandManager is not defined either. | |
} |
The problem is that editor.commands
is undefined.
So if I actually console.dir(editor)
there is no property on the editor object for commands
?
The one I just pushed to github has it http://ace.ajax.org/build/kitchen-sink.html
type env.editor.commands
in the console.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'editor.commands.addCommand' is the correct way to do it. 'editor.commands' is rather new though.