key-bindings

How can I assign the 'Close on Escape-key press' behavior to all WPF windows within a project?

99封情书 提交于 2019-11-30 01:43:27
Is there any straightforward way of telling the whole WPF application to react to Escape key presses by attempting to close the currently focused widow? It is not a great bother to manually setup the command- and input bindings but I wonder if repeating this XAML in all windows is the most elegant approach? <Window.CommandBindings> <CommandBinding Command="Close" Executed="CommandBinding_Executed" /> </Window.CommandBindings> <Window.InputBindings> <KeyBinding Key="Escape" Command="Close" /> </Window.InputBindings> Any constructive suggestions welcome! All I can suggest to improve on that is

Emacs name of current local keymap?

梦想的初衷 提交于 2019-11-29 20:59:58
问题 I am writing an elisp function that permanently binds a given key to a given command in the current major mode's keymap. For example, (define-key python-mode-map [C-f1] 'python-describe-symbol) The command and the key sequence are gathered interactively from the user. However, I am having trouble producing the name of the KEYMAP (e.g. 'python-mode-map') that corresponds to the current major mode. I have tried the function (current-local-map), but this function returns the keymap object itself

Emacs: print key binding for a command or list all key bindings

大憨熊 提交于 2019-11-29 18:42:25
In Emacs (GNU 23.2, *nix), how can I: list the key sequences bound to a particular command? For example, how can we list all the key sequences that execute save-buffers-kill-emacs , with the output of key sequences bound to it? Assuming we can do this, listing the key sequences bound to goto-line should print the output: M-g g on a default install. list all key-bindings? Does C-h b do this? Would it print my own bindings? I am aware that executing the command directly can print a key sequence it can be activated with, but it doesn't always do so, and a few things happen, including: (1) the

Java keyboard input - game development

最后都变了- 提交于 2019-11-29 17:59:28
I have a specific "problem" with a game I'm creating for class. The game is an implementation of "Break it". To move the platform at the bottom I just used a key listener. The problem is that after the first key press there is a short "lag" or "stutter" before the platform starts moving. How could I prevent this to get a smooth response? Is there another way than KeyListener? KeyBindings? Here is the key listener implementation private class KeyControl implements KeyListener { private int dx = 20; public void keyPressed(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_RIGHT) { if(dx < 0 ) dx =

JTable Key Bindings

送分小仙女□ 提交于 2019-11-29 16:31:24
I want to trigger an save action anywhere in my application (Control+S). I've added the necessary key binding, and the action triggers as expected. However, if I try Control+S on a JTable the table starts my custom action and activates the table cell for editing. I think I've disabled the edit action in the table's input map. What am I missing here? import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JOptionPane;

Pong Controls With KeyListener

别来无恙 提交于 2019-11-29 16:08:16
I have ran into a bit of trouble getting my pong game to work, this project started simply with making a ball have physics but then i decided to do some more work I have that ball bounce back and forth and all but the keys W and S wont control player one and the up and down arrow keys dont control player 2 public void keyPressed(KeyEvent e){ if(e.getKeyCode() == e.VK_UP){ p2Y -= 3; System.out.println("UP"); } if(e.getKeyCode() == e.VK_DOWN){ p2Y += 3; System.out.println("Down"); } if(e.getKeyCode() == e.VK_W){ p1Y -= 3; System.out.println("Up"); } if(e.getKeyCode() == e.VK_S){ p1Y += 3; System

How do you make key bindings for a java.awt.Frame?

喜你入骨 提交于 2019-11-29 15:30:26
Background My window is a java.awt.Frame, and inside of the Frame are two Panels (java.awt.Panel). I'm trying to make it so that the window handles buttons I press. Try Number 1 I tried using a KeyListener, making the Frame implement the KeyListener. I added the KeyListener to the Frame, but the KeyListener functions didn't do anything when I pressed keys. (I tried printing with System.out.println().) Try Number 2 I tried following this tutorial: http://tips4java.wordpress.com/2008/10/10/key-bindings/ . Here is the my attempt to handle pressing the SPACEBAR: public void registerActions(){ //01

File-specific key-binding in emacs

自闭症网瘾萝莉.ら 提交于 2019-11-29 15:23:58
Is it possible to define file specific key-bindings in emacs? I suppose it would be possible to create a minor mode and have it loaded when the particular file is open but for only one key-binding that seems overkill. phils If you combine the code to local-set-key and Buffer-locally overriding minor-mode key bindings in Emacs then you could end up with something like this: (defun my-buffer-local-set-key (key command) (interactive "KSet key buffer-locally: \nCSet key %s buffer-locally to command: ") (let ((oldmap (current-local-map)) (newmap (make-sparse-keymap))) (when oldmap (set-keymap

How To Add ShortCut Keys to JTextField?

雨燕双飞 提交于 2019-11-29 14:39:58
I am Stuck in some Step that I Can't Add a Shorcut Key like: CTRL + SPACE to my program , I am Searching for one week and I could'd find any answers . You'll want to look at the Java Tutorial for a good overview of Key Bindings. Here's a quick example: import java.awt.event.*; import javax.swing.*; public class KeyBindings extends Box{ public KeyBindings(){ super(BoxLayout.Y_AXIS); final JTextPane textArea = new JTextPane(); textArea.insertComponent(new JLabel("Text")); add(textArea); Action action = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { textArea.setText

How do you make key binding for a JFrame no matter what JComponent is in focus?

白昼怎懂夜的黑 提交于 2019-11-29 14:00:42
How do we make key bindings for a JFrame regardless of what's in focus in the frame? I already looked at this question: How do you make key bindings for a java.awt.Frame? I tried setting the input map for the root pane of the JFrame, but it doesn't work when the focus is on a JTextArea even though editable is false. What's the easiest way to make key bindings work across an entire JFrame? I tried setting the input map for the root pane of the JFrame, but it doesn't work when the focus is on a JTextArea even though editable is false. Correct. If a component has focus and implements the same