Add examples for new command.bindKey to demo.js, update Pilot & Cockpit
This commit is contained in:
parent
c27fd43ebd
commit
c428908211
4 changed files with 67 additions and 7 deletions
64
demo/demo.js
64
demo/demo.js
|
|
@ -40,7 +40,7 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
exports.launch = function(env) {
|
||||
|
||||
var canon = require("pilot/canon");
|
||||
var event = require("pilot/event");
|
||||
var Editor = require("ace/editor").Editor;
|
||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||
|
|
@ -354,6 +354,68 @@ exports.launch = function(env) {
|
|||
});
|
||||
|
||||
window.env = env;
|
||||
|
||||
/**
|
||||
* This demonstrates how you can define commands and bind shortcuts to them.
|
||||
*/
|
||||
|
||||
// Command to focus the command line from the editor.
|
||||
canon.addCommand({
|
||||
name: "focuscli",
|
||||
bindKey: {
|
||||
win: "Ctrl-J",
|
||||
mac: "Command-J",
|
||||
sender: "editor"
|
||||
},
|
||||
exec: function() {
|
||||
env.cli.cliView.element.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Command to focus the editor line from the command line.
|
||||
canon.addCommand({
|
||||
name: "focuseditor",
|
||||
bindKey: {
|
||||
win: "Ctrl-J",
|
||||
mac: "Command-J",
|
||||
sender: "cli"
|
||||
},
|
||||
exec: function() {
|
||||
env.editor.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Fake-Save, works from the editor and the command line.
|
||||
canon.addCommand({
|
||||
name: "save",
|
||||
bindKey: {
|
||||
win: "Ctrl-S",
|
||||
mac: "Command-S",
|
||||
sender: "editor|cli"
|
||||
},
|
||||
exec: function() {
|
||||
alert("Fake Save File");
|
||||
}
|
||||
});
|
||||
|
||||
// Fake-Print with custom lookup-sender-match function.
|
||||
canon.addCommand({
|
||||
name: "save",
|
||||
bindKey: {
|
||||
win: "Ctrl-P",
|
||||
mac: "Command-P",
|
||||
sender: function(env, sender, hashId, keyString) {
|
||||
if (sender == "editor") {
|
||||
return true;
|
||||
} else {
|
||||
alert("Sorry, can only print from the editor");
|
||||
}
|
||||
}
|
||||
},
|
||||
exec: function() {
|
||||
alert("Fake Print File");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -98,10 +98,8 @@ var KeyBinding = function(editor) {
|
|||
};
|
||||
|
||||
this.onCommandKey = function(e, hashId, keyCode) {
|
||||
key = (keyUtil[keyCode] ||
|
||||
String.fromCharCode(keyCode)).toLowerCase();
|
||||
|
||||
this.$callKeyboardHandler(e, hashId, key, keyCode);
|
||||
var keyString = keyUtil.keyCodeToString(keyCode);
|
||||
this.$callKeyboardHandler(e, hashId, keyString, keyCode);
|
||||
};
|
||||
|
||||
this.onTextInput = function(text) {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 1fa3516d4d553af9f6edd81c20023bcfab08c2a3
|
||||
Subproject commit 7362e0331327321f4d743ad70a8ded16327443f2
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 5d07cccd2e8d0ca22b170693afda5199a69de062
|
||||
Subproject commit c5a615beea2b6cda2920bc2779dae33065009939
|
||||
Loading…
Add table
Add a link
Reference in a new issue