I have an Ace Text Editor enabled input field. I am attempting to execute an action through the keyboard shortcut combination of Shift+Enter, which is handled in my CoffeeScript file. Unfortunately, there seems to be a bug that Shift+Enter is automatically entering a newline character (presumably because defaults from Ace are not being overwritten). I would like the CoffeeScript keyboard shortcut to take precedence. Can someone point me in the right direction of how I could approach this?
You can call event.preventDefault() and event.stopPropagation() from coffeescript handler to not allow the event to reach ace or use handler in ace like: editor.commands.bindKey("Shift-Enter", function() {...})
Related
I've seen a ton of questions about TinyMCE shortcuts, but nothing quite like this.
I have a situation in which I am iterating over an object of shortcuts I want to add to TinyMCE.
The shortcuts add functionality for the greater app around the editor.
For the most part, it works fine.
However, it appears that I cannot add certain combinations. For example, alt+l and alt+left.
Take this code:
_.each(oHotKeyCollection, function (oHotKey, sHotKey) {
this.editor.addShortcut(sHotKey, oHotKey.note, function (e) {
if (!e) {
e = event;
}
// sHotKey is the pattern (ie. alt+l)
alert(sHotKey)
oHotKey.execute(e);
}.bind(this));
}
}.bind(this));
When alt+l is added, and then alt+left is added, hitting alt+l on the keyboard will bring up an alert with alt+left.
Removing the alt+left shortcut allows alt+l to function as expected.
The same behaviour seems to be true of alt+r and alt+right as well as alt+u and alt+up.
How I can get both shortcuts working?
The problem is that only certain keywords can be used in a shortcut, such as the modifier names (ctrl, alt, etc...). Anything else is treated as a single key so left in this case isn't valid and is treated as just being l (see Shortcuts.ts). That's why alt+l is being overridden with your alt+left behavior.
So to fix that, you'll need to use the keycode for left instead of a keyword. In this case that would be alt+37. Here's a fiddle showing that working by printing to the console: https://fiddle.tiny.cloud/EEhaab.
Since you also mentioned you're trying to register other arrow keys, here's the key combinations you'd need to use:
Left: alt+37
Right: alt+39
Up: alt+38
Down: alt+40
How to trigger a popup with documentation for identifier under the cursor?
Normally it appears when hovering the identifier using the mouse pointer:
I would like to achieve this effect using a command or keyboard shortcut.
The only related commands I found are: trigger completion (which doesn't show the function doc) and trigger parameters hint (which only works when the cursor is inside function call - parameters list).
This is the editor.action.showHover command. It is bound to cmdk cmdi by default.
Note: Shortcut works by holding down the cmd [ctrl in windows], then while holding press k then i
You can change the keyboard shortcut with a keybinding such as:
{
"key": "cmd+k ctrl+space",
"command": "editor.action.showHover",
"when": "editorTextFocus"
}
The default shortcut for Trigger Parameter Hints is Ctrl+Shift+Space
You also have, with VSCode 1.40 (Oct. 2019):
Definition Preview Hover from the keyboard
There is a new command Show Definition Preview Hover for better accessibility of the definition preview hover widget, which can be triggered by hovering a symbol with the mouse and pressing a modifier key dependent on the platform and configuration.
Previously, only the command Show Hover was provided, which is equivalent to hovering the mouse cursor over a symbol.
Now, with Show Definition Preview Hover, the detailed hover information can be shown via the keyboard.
To make this more graphic, check these steps:
In Visual Studio 2019 for Mac, I couldn't find anything about "hover" in the Key Bindings setting. The relevant command seems to be called "Show quick info" and is bound by default to Cmd + F1.
I know this question is about VSCode but I could only find this question when trying to search for an answer. Therefore I would also like to leave the information here in case somebody finds it useful.
There are multiple ways to trigger the documentation popup:
First: Using shortcut ctrl + space
Second: Using vscode extension:
Here is the documentation:
Each answer here demonstrates a different function. Below is a consolidation of every type of helpful popup, the context in which they come up and all the ways I know to trigger them.
These assume default settings.
Function: Display documentation
Shortcut: Ctrlk Ctrli
Scope: Works over named elements - variable and function names (does nothing over literals).
Can display function documentation:
or variable or even property information:
This is the same pop-up you get when you hover over the element briefly.
Function: Display parameter hints.
Shortcut: CtrlShiftSpace
Scope: Works inside a function call.
The cursor must be inside the parenthesis that contain the passed arguments. Does nothing outside that scope.
Can also be triggered by typing a comma, as if passing another argument.
Up/Down arrows can be used to cycle through overloaded definitions (instead of moving the cursor up and down the document).
Function: Display the code completion menu
Shortcut: CtrlSpace
Scope: Anywhere. Will adapt to the context. In strings will display words only. In code will offer symbol hints - function names, variable names within the current scope, known properties, etc.
Is case insensitive.
Matches all contained characters - they do not have to be consecutive (see image above).
Tab or Enter accepts the currently selected suggestion.
Symbol hints can be triggered by just typing letters. Inside strings you must use the keyboard shortcut.
I have an editor which is linked to a database field.
When the user pushes certain keys the program should behave differently,
for the rest of keys it should maintain the default behaviour. I am using this part of code:
ON ANY-KEY OF editor_1 IN FRAME F-Main
DO:
APPLY LAST-EVENT:LABEL TO SELF.
RETURN NO-APPLY.
END.
The problem is that when APPLY LAST-EVENT:LABEL is executed the editor does not behave as default.
Some examples of the behaviour by default, i.e. when any-key is not triggered:
CTRL+C is used for copying selected text
CTRL+V is used for pasting the copyed text
After triggering any-key in the editor, the program works like this:
CTRL+C aplication ABORTS
CTRL+V does not work
CURSORS DOWN/RIGHT/LEFT/UP do not work
BACKSPACE does not work
Is there anyway of triggering any-key without overwritting the default behaviour?
Note: Progress 4GL is v11.3 and is executed from windows.
You should map the key labels to the key FUNCTION that you want to apply.
Something like:
ON ANY-KEY OF editor_1 IN FRAME F-Main
DO:
if last-event:label = "backspace" then
apply delete-char to self.
else
apply lastkey to self.
/* use a CASE statement to extend this... */
RETURN NO-APPLY.
END.
I talked to progress and there is no solution for this issue. This issue with ANY-KEY is related to editors.
You could map some key labels to specific key FUNCTION, but there are certain events where it is not possible (for example, cursor movements).
At the end I had to trigger for special keys, but in this particular case it was preferable something like ANY-KEY.
Instead of triggering an event on any key, why not just do it for those special keys?
For example, the control-C behavior would be in this trigger:
ON CTRL-C of editor_1 IN FRAME F-Main
When editing an HTML file, if the cursor is on an opening tag, the matching tag is highlighted in the editor. I would like to be able to map a key combination like alt+→ (or something) to go to the closing tag. I looked for an existing action like this in tools->options->keymap, but did not find one, so I decided to try to create a macro for it. I have found that I can do it in multiple steps like this: ctrl+/ (fold code), →, ctrl+* (unfold code). I recorded a macro of this, and it produced this code:
collapse-fold-tree caret-forward expand-fold-tree
Unfortunately, when I run the macro, the cursor stays in the same place, rather than ending up at the end of the closing tag like it does when I do the steps manually. I have successfully created a macro that moves from the closing tag to the opening tag with:
collapse-fold-tree expand-fold-tree
but I cannot get the forward one working. I am also having a bad feeling that I just overlooked the action in the keymap settings and am now trying to reinvent that wheel. Is this an action that is already there? And if not, does anyone know how I might get the macro to work?
There is an existing action in the keymap for this. It is called "Insertion Point to Matching Brace". The shortcut is ctrl + [ or command +[ in Mac.
There is also shortcut Ctrl + Shift + [, which selects content inside this tag.
Is there something I can press on the keyboard to get Pycharm to auto-complete without my first having to type a letter?
The purpose of this is so I can see all the possibilities as opposed to only the ones that start with the letter that I typed, or if I don't know what any of the possibilities are to begin with.
Example:
You can trigger different types of completion from the menu Code → Completion or using the corresponding keyboard shortcuts (depend on keymap):
Default completion shortcuts:
Basic: Ctrl+Space
SmartType: Ctrl+Shift+Space
Class Name: Ctrl+Alt+Space