key-bindings

How to set an accelerator for a JMenu sub menu?

南笙酒味 提交于 2019-12-12 12:20:47
问题 I have a user request to add an accelerator to a sub menu (JMenu) which would allow the user to press the short cut and have the corresponding sub menu "fold out", showing its contained menu items. I don't recall every having seen something like this (either in Java or any other language). Our application is written in Java using Swing. We have a number of JMenuItems with accelerators that work well, but when I attempted to add an accelerator to JMenu I get the following exception: java.lang

Performing a certain task after pressing “ctrl” + “alt” + “backspace”

元气小坏坏 提交于 2019-12-12 11:22:08
问题 How do I code it when I want to perform something. Let's say that the focus on a JTextField and a messagebox will pop up when the user pressed ctrl + alt + backspace at the same time. 回答1: An example with key bindings: import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import javax.swing.*; public class JTextFieldMagic { public static final String CTRL_ALT_BACK_SPACE = "ctrlAltBackspace"; public static void main(String[] args) { JTextField field = new JTextField(10); int

Java swing keybinding

非 Y 不嫁゛ 提交于 2019-12-12 11:01:19
问题 This is in the constructor of a JPanel but it does not print anything when I press "h". If more code is needed, I can provide it. Thank you! String hide = "hide"; this.getInputMap().put(KeyStroke.getKeyStroke('h'), hide); this.getActionMap().put(hide, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.out.println("HIDDEN"); if (isHidden){ slide.setVisible(true); }else{ slide.setVisible(false); } } }); 回答1: this.getInputMap().... You are trying to add the

Bind any key pressed to command in VM WPF

人走茶凉 提交于 2019-12-12 10:37:24
问题 I'm trying to bind any keyboard key pressed to a command in the ViewModel . I know that I can bind a specific key, using: <Window.InputBindings> <KeyBinding Command="{Binding ChangeIdCommand}" Key="B"/> </Window.InputBindings> Can I bind all key presses to ChangeIdCommand without having to type them all manually? 回答1: Try this after your window definition: <Window x:Class="wpfApplication.MainWindow" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" ...> <i:Interaction

How to find the location, where an an Emacs Lisp function is bound to a key?

為{幸葍}努か 提交于 2019-12-12 09:01:55
问题 I'm trying to figure out where M-m is bound to back-to-indentation function. When I issue C-h k M-m ( describe-key ), I get the following output M-m runs the command back-to-indentation, which is an interactive compiled Lisp function in `simple.el'. It is bound to M-m. (back-to-indentation) Move point to the first non-whitespace character on this line. When I look at simple.el , I'm seeing only the definition of function back-to-indentation . I searched throughout the file and I didn't see

KeyListener/KeyBinding does not trigger consistently

随声附和 提交于 2019-12-12 05:59:03
问题 I am trying to make a simple game, and i need my spaceship to rotate on its centre (using A and D keys) , and move relative to the direction it is facing (W and S Keys). I got the math for the movement and rotation mostly figured out, but im having an issue with the key listeners. When i compile, the key listener works fine for th e first couple of key presses. But if i hold down A (rotate left while being pressed down) and then switch to D and then switch to A again, it stops working. Any

pre-fill bash/readline incremental search query?

我怕爱的太早我们不能终老 提交于 2019-12-12 04:33:02
问题 Can I, with bash bind , hand a string given by some function to pre-fill a \C-s query? I was hoping I could do bind '"\e\C-i": "\C-s$(echo "$FOO")\C-j"' but that just searches for the exact (unexpanded) $(echo "$FOO") . 回答1: readline doesn't support evaluating shell expressions in macros, but there is a workaround. Introduce two auxiliary key sequence bindings such that The first one performs a forward search history operation with a fixed query string. The second one configures the first one

Creating a “Repeat last macro” keybinding in sublime text vintage mode

亡梦爱人 提交于 2019-12-12 03:55:42
问题 At the moment, I am trying out sublime text. Most of it is fine, but there is one big feature that I can't figure out how to implement in sublime text. In vim, have have space bound to repeat the last macro that I performed. However, I can't find a good way to implement it in sublime text. In an effort to learn more, I looked at the macro key bindings in the vintage package: { "keys": ["q"], "command": "vi_end_record_macro", "context": [{"key": "setting.command_mode"}, {"key": "is_recording

Override (globally override key binding in emacs) temporarily

北慕城南 提交于 2019-12-12 03:18:38
问题 I use the method stated here : globally-override-key-binding-in-emacs (defvar my-keys-minor-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-i") 'some-function) map) "my-keys-minor-mode keymap.") (define-minor-mode my-keys-minor-mode "A minor mode so that my key settings override annoying major modes." ;; Define-minor-mode will use `my-keys-minor-mode-map' for us. :init-value t :lighter " my-keys") (defun my-keys-keep-on-top (&rest _) "Try to ensure that my keybindings

Add simple keybinding in Atom

只愿长相守 提交于 2019-12-12 02:52:03
问题 How can I add a keybinding in Atom to run rustfmt on the current file? Do I have to create or install a package? Can I attach it to the "Editor: Auto Indent" command? How do I find out which package Auto Indent comes from? 回答1: There is a package called atom-beautify which seems to have preliminary support for rustfmt. 来源: https://stackoverflow.com/questions/31761199/add-simple-keybinding-in-atom