| Summary: | Way to override default key bindings in Orion Code Edit | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Brian Gleeson <brian.gleeson> |
| Component: | Client | Assignee: | libing wang <libingw> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P2 | CC: | libingw |
| Version: | 14.0 | ||
| Target Milestone: | 15.0 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Brian Gleeson
Hi Brian, can you try http://wiki.eclipse.org/Orion/How_Tos/Code_Edit#How_to_override_an_editor.27s_default_action? the action you want to override is "escape". Just replace "gotoLine" in the example with "escape" and see. I give it a quick try like:
editorViewer.editor.getTextView().setAction("escape", function(){
console.log("my action invoked!");
return true;
});
And it works
You can also override any reserved keybindings by the following snippet. Details also addressed in https://wiki.eclipse.org/Orion/How_Tos/Code_Edit#How_to_know_the_reserved_keybindings. var actionID = editorViewer.editor.getTextView().getKeyModes()[0].match({keyCode:27/*esc*/, type: "keydown", metaKey: false, shiftKey: false, altKey: false, ctrlKey: false}); if(actionID) { editorViewer.editor.getTextView().setAction(actionID, function(){ console.log("my action invoked!"); return true; }); } I am trying to find a better way, instead of using editorViewer.editor.getTextView().getKeyModes()[0]. I will update the wiki. Please stay tuned. In the perfect world, you should add your own keymode into the wdiget. Refer to https://github.com/eclipse/orion.client/blob/master/bundles/org.eclipse.orion.client.editor/web/orion/editor/contentAssist.js, around the line of ContentAssistMode.prototype = new mKeyModes.KeyMode(); However, this coding pattern requires 'orion/keyBinding', etc, which are only available in the requirejs build of the widget. In the almond build, we are not exporting orion modules yet. I am closing this bug now. |