本文整理汇总了TypeScript中mousetrap.bindGlobal函数的典型用法代码示例。如果您正苦于以下问题:TypeScript bindGlobal函数的具体用法?TypeScript bindGlobal怎么用?TypeScript bindGlobal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bindGlobal函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createKeyBinding
function createKeyBinding(name, description, preventDefault, pressAction) {
var keyBinding = parseKeyBinding(name);
// var editor = ace.edit("editor");
//
// console.log(keyBinding.editor);
// editor.commands.addCommand({
// name : name,
// bindKey : {
// win : keyBinding.editor,
// mac : keyBinding.editor
// },
// exec : function(editor) {
// if(pressAction) {
// pressAction();
// }
// }
// });
keyBindings[keyBinding.editor] = Common.escapeHtml(description);
FileEditor.addEditorKeyBinding(keyBinding, pressAction);
Mousetrap.bindGlobal(keyBinding.global, function(e) {
if(pressAction) {
pressAction();
}
return !preventDefault;
});
}
示例2: function
commandRegistry.forEach(c=> {
if (c.config.context == CommandContext.Global
&& c.config.keyboardShortcut) {
Mousetrap.bindGlobal(c.config.keyboardShortcut, function() {
c.emit({});
return !!c.config.allowDefault;
});
}
});
示例3: createKeyUpBinding
function createKeyUpBinding(name, preventDefault, pressAction) {
var keyBinding = parseKeyBinding(name);
Mousetrap.bindGlobal(keyBinding.global, function(e) {
if(pressAction) {
pressAction();
}
return !preventDefault;
}, 'keyup');
}
示例4: register
export function register() {
commandRegistry.forEach(c=> {
if (c.config.context == CommandContext.Global
&& c.config.keyboardShortcut) {
Mousetrap.bindGlobal(c.config.keyboardShortcut, function() {
c.emit({});
return !!c.config.allowDefault;
});
}
});
// Commands with multiple key bindings
// enable at some point
Mousetrap.bindGlobal('mod+h', function() { // atom,sublime,c9
findAndReplace.emit({});
return false;
});
}