key-bindings

How do you remove the Ctrl+C action on a JFileChooser?

China☆狼群 提交于 2019-11-29 13:38:07
I'm embedding a JFileChooser in my program in my own frame with other custom components in the frame. Here's a design of my app as it may help visualize my issues: If you can't tell, the lists directly under the JFrame titles are JFileChoosers . The way this is supposed to work is you assign shortcuts to destinations and then when you press those shortcut keys, the selected file moves to the destination. My strategy for doing this is to assign the shortcut to a javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW scope of the InputMap of the entire frame. But what's annoying is that something (I

Java: Use keystroke with arrow key

廉价感情. 提交于 2019-11-29 11:28:42
I have some code that I need to modify. In the code, the original author uses KeyStroke.getKeyStroke to take user input. In this code, for example, he uses a instead of left arrow. I want to change this, but I don't know how. Here is the original code: registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { tick(RIGHT); } }, "right", KeyStroke.getKeyStroke('d'), WHEN_IN_FOCUSED_WINDOW ); I have to change it to something like this, but when run, it doesn't work: KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT); KeyStroke.getKeyStroke("RIGHT"); Do start the program

How can i make multiple Key Bindings work at the same time?

对着背影说爱祢 提交于 2019-11-29 08:54:54
I need to design a game with two players. Each has a ball and should be able to move the ball to right or left, the first player with 'a' 'd' buttons and the second player with right,left arrow buttons. However currently one player needs to wait for the other player's action to be completed in order to move their own ball. How can i resolve that problem? Here is the related parts of my code: public class AnimationWindow extends JPanel{ public AnimationWindow() { super(); .... .... cezmiMover(); } public void cezmiMover(){ this.getInputMap().put(KeyStroke.getKeyStroke('a'), "left1"); this

How do I bind a key to “the function represented by the following key sequence”?

。_饼干妹妹 提交于 2019-11-29 06:52:38
I'm just starting to learn emacs (woohoo!) and I've been mucking around in my .emacs quite happily. Unfortunately, I don't know Lisp yet, so I'm having issues with the basics. I've already remapped a few keys until I fix my muscle memory: (global-set-key (kbd "<f9>") 'recompile) That's fine. But how can I tell a key to 'simulate pressing several keys'? For instance, I don't know, make <f1> do the same as C-u 2 C-x } (widen buffer by two chars). One way is to look up that C-x } calls shrink-window-horizontally , and do some sort of lambda thing. This is of course the neat and elegant way (how

Java Keybinding Plus Key

回眸只為那壹抹淺笑 提交于 2019-11-29 04:25:13
I was trying to create shortcuts for zooming in and out in an image editing application I'm creating and I noticed something strange. To bind the combination of ctrl + + , I had to use the = key and a control and shift mask: getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK),"ZoomIn"); Neither of the combinations where I tried to directly bind to VK_PLUS worked: getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK),"ZoomIn"); getInputMap().put(KeyStroke.getKeyStroke(KeyEvent

Emacs key binding for multiple commands

泪湿孤枕 提交于 2019-11-29 02:48:20
问题 I'm new to emacs, and have a rookie question. I can bind a key to a particular function by (global-set-key (kbd "C-c a b c") 'some-command) , where some-command is a function. How can I invoke two functions (say some-command and some-other-command ) with one key binding? Thanks a lot! 回答1: You can define your own function which call the two functions, and bind the key to your own function. Or use a simple lambda: (global-set-key (kbd "C-c a b c") (lambda () (interactive) (some-command) (some

JavaFX: scrolling vs. focus traversal with arrow keys

纵饮孤独 提交于 2019-11-29 02:26:29
I got a ScrollPane containing focusable Nodes. The current default behaviour is: Shift + ← , ↑ , → , ↓ moves the focus ← , ↑ , → , ↓ scrolls the view I want it the other way around. How can I accomplish this or where should I start? [EDIT] Well, there is another fragile approach. Instead of messing around with the events, one could mess around with the KeyBinding s. scrollPane.skinProperty().addListener(new ChangeListener<Skin<?>>() { @Override public void changed(ObservableValue<? extends Skin<?>> observable, Skin<?> oldValue, Skin<?> newValue) { ScrollPaneSkin scrollPaneSkin =

Show Emacs keybindings which start with a particular key

倾然丶 夕夏残阳落幕 提交于 2019-11-29 01:43:55
问题 I've read this, but my question is different. I'd like to know how to view key-bindings in Emacs which start with a particular key. I'd like to bind f2 , but would like to know what it's currently bound to. Pressing C-h m prompts for the key sequence. Entering f2 here results in Emacs waiting for me to complete the chain, as f2 alone does nothing. How can I view all key-bindings which start with f2 ? 回答1: F2 F1 or F2 C-h In general, typing F1 or C-h after any prefix-binding will list all the

How to hook/remap an arbitrary keyboard event on OSX?

妖精的绣舞 提交于 2019-11-29 00:12:33
I would like to map: CAPS-LOCK to Fn Fn to Left-MOUSE LSHIFT + 3 to # RSHIFT + 3 to something else etc. I have searched exhaustively for any tool that offers complete freedom for remapping keyboard input, but cannot find one. (Windows has AutoHotkey). I'm planning to write my own tool that parses a config file. But how to actually dig in and do this? Solving this problem will require a thorough understanding of the journey of a keystroke through the operating system, so as to intercept at the appropriate point. I think I need to eat the event at a low-level, where it is still a virtual key

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

巧了我就是萌 提交于 2019-11-28 22:33:06
问题 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" />