How to prevent VSCode to apply a keybinding - jupyter-notebook

I encounter an issue while using the Notebook preview on VSCode (MacOS; VSCode 1.71.2 (Universal)).
Step to reproduce:
Create a .iypnb document
In a code cell, enter
%%html
<input>
Run the cell and focus on the input field
Press M key
Current behavior:
VSCode catches the key press and dispatches an event that turns the cell to a Markdown cell. This is the correct key binding in my VSCode configuration.
How it is a problem:
I cannot properly type in custom components (either mines, or the ones from other libraries that render text as HTML). Rendering as HTML is a key feature of the IPython Kernel; VSCode catches too many key bindings. I have similar issue for all my bindings.
How to workaround (undesirable solution):
The only solution I've found for now is to remove the bindings of VSCode for the notebook preview. This is undesirable, as it affects my workflow.
Question: Is there a way to prevent VSCode to apply its binding when the focus in somewhere in the output of a cell?

Related

How to edit jupyter notebook shortcuts

Jupyter notebooks have a convenient means to edit shortcuts - by pressing H for help there is a button for it:
And here is the dialog to make the updates:
The question here is: when pressing add shortcut we apparently have a free form text field to enter the shortcut:
But whatever combination I put in actually causes some _system_wide_ kind of behavior to kick-in e.g. Command-R causes Jupyter to do something wacky, and I tried a couple of others. Is there another way to enter these?
Have you tried clicking on that link: details of defining keyboard shortcuts?
That gives some general tips on creating new shortcuts.
Your example might not work because you would want to use "Cmd-R" instead of "Command-R". Though, in my operating system, "Cmd-r" already does something(reloads the page). So whatever combination or sequence you choose, I'd make sure it doesn't already do something before using it as a shortcut.
Once you type into the field, are you clicking the "+" button to the right? If you click on that, it should then show if it's been set, and you can verify it set it to what you wanted. If you don't click the "+" button, it will have no effect.
Good luck!

Qt Designer add '&' (ampersand) in text automatically

I am using Qt 5.11.1 on Manjaro Linux.
When I open Qt Designer, create a new dialog and add stuff on the widget, Qt Designer adds '&' (ampersand) in the text in some types of widgets automatically. (Ampersand "&" is shortcut in Qt, commonly referred to as "mnemonic". For example, if text of button is "b&utton", I can click the button with Alt + U. See this answer for more information.) For example, if I create a radio button and set the text to "button", the text will become "b&utton" automatically, and I cannot remove the '&'. What should I do?
Not sure, probably qt_set_sequence_auto_mnemonic function is what you are looking for.
Specifies whether mnemonics for menu items, labels, etc., should be honored or not. On Windows and X11, this feature is on by default; on macOS, it is off. When this feature is off (that is, when b is false), QKeySequence::mnemonic() always returns an empty string.
Note: This function is not declared in any of Qt's header files. To use it in your application, declare the function prototype before calling it.
The workaroud in How to disable automatic mnemonics in a Qt application on KDE? works. Thank you Andrii for providing the link!
The workaroud is to add
[Development]
AutoCheckAccelerators=false
to ~/.config/kdeglobals.
I also found that removing the package kdelibs4support is also a workaround, but some packages might depend on it.

Select only files with QFileDialog [PyQT]

I'm trying to use the QFileDialog widget in PyQT in order to get the name of a file to save results. I'm using the method QFileDialog.getSaveFileName() and, as is expected, if I select an existing file a warning box appears saying that the file exists and offering the possibility to overwrite it. But the problem is that if I select a directory instead of a regular file the same warning box as if it was a normal file appears. I don't like this behavior and I would like a warning box informing there is a directory and it can't be selected, or maybe the OK button disabled until a regular file is selected. Is possible to do? How can I do this, if it is possible?
Thanks
The static functions will open a native dialog, unless you set DontUseNativeDialog with the options parameter, in which case you will get the built-in Qt file-dialog:
path = QFileDialog.getSaveFileName(options=QFileDialog.DontUseNativeDialog)
The built-in dialog is often faster, and generally has more sensible behaviour than the native dialogs. In particular, if you single-click a directory, the Save button changes to an Open button, so a directory can never be selected.
If you absolutely must have an native dialog, you could try setting the DontConfirmOverwrite option. This will allow you to handle any potential overwriting yourself after the dialog has closed.

Entering Text in Textbox of a jar File using Shell Script

I have a graphical interface in jar file. There is a text box in there and a button in the window. I manually enter the text into it and then click the button to get the required output.
Now I want to make this thing automatic using a shell script. I wish to pass my input file using redirection. The shell script should open the jar file copy the text in the text box and click the button automatically so that I get the result instantaneously. Could anyone suggest something?
I don't think there's a out of the box solution for this, what I can think about is :
Create a simple java class which is the launcher of your GUI java app and to perform operations like typing and button click like
Using java Robot class. Refer this post or
Using a GUI testing utility like fest to do those user operations automatically

How to commit build settings in popover on Xcode

In Xcode 4.3.1, I am having extreme difficulty whenever I try to change a build setting such as "Other Linker Flags".
If I double-click, a pop-up shows which ostensibly allows you to add/remove values. However, there is no "done" button and all key combinations I've tried (enter/command-enter/etc...) fail to commit the values I've entered.
It is possible to enter a value without the pop-up by /slow/-double-clicking (WTF, Apple?!?) the edit line. This works, but why the heck does is the pop-up the default double-click result when it seems to be totally useless, misleading and annoying?!?!
A similar question is Editing Build Settings in xcode 4 but bugloaf's question of what to do when there is no "done button" remained unanswered.
This is more to do with how to interact with popovers in OS X in general. "Transient" popovers force you to click outside them to dismiss. Whatever changes you make inside them should always be "committed" by the time the popover is dismissed. This is standard Mac behavior.
So to answer the unanswered question: Click outside the popover to dismiss/commit.
As you ssuggested, you can slow-double-click (once to select, pause, once to begin editing cell) to edit text cells inline without the popover. This is also standard Mac behavior.
The double-click action is a secondary effect and can be taken to mean "give me a bigger editor for this field" - this seems to be just Xcode behavior. File bug reports if you think there should be a better mechanism. Be prepared to describe a better mechanism.

Resources