key-bindings

How to create a binding for NSApp.dockTile's

社会主义新天地 提交于 2019-12-08 01:35:55
问题 In IB it is easy to bind a label or text field to some controller's keyPath. The NSDockTile (available via [[NSApp dockTile] setBadgeLabel:@"123"]) doesn't appear in IB, and I cannot figure out how to programmatically bind its "badgeLabel" property like you might bind a label/textfield/table column. Any ideas? 回答1: NSDockTile doesn't have any bindings, so your controller will have to update the dock tile manually. You could do this using KVO which would have the same effect as binding it.

Java KeyBindings with JFileChooser

坚强是说给别人听的谎言 提交于 2019-12-07 18:53:50
问题 I would like to add Key bindings to my JFileChooser in order to open a file preview window when the SPACE key is pressed. Because of the source code is too big, I just did a simple dirty code : MainWindow.java package test; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MainWindow extends JFrame { public MainWindow() { this.setTitle("Test Window"); Dimension dim = new Dimension(800, 600); this.setSize(dim); this.setPreferredSize(dim); MainPanel pane = new

Java Swing: Do something while the key is being pressed

↘锁芯ラ 提交于 2019-12-07 10:56:01
问题 Im using a KeyAdpater to get the events and the method addKeyListener and works fine. The problem is that when a press the key, the action ocurrs only once and not while its being pressed, after 3-4 secs holding down the key the action occurs all the time which is what I want. I'd want to know if there is good way to do the action all the time the key is being pressed from the very begining , not after 3-4 seconds holding down. I thought on the next solution, but maybe there is already an

How to make “Enter” Key Behave like Submit on a JFrame

心已入冬 提交于 2019-12-07 08:46:00
问题 I'm Building a Client/Server application. and I want to to make it easy for the user at the Authentication Frame. I want to know how to make enter -key submits the login and password to the Database (Fires the Action) ? 回答1: One convenient approach relies on setDefaultButton(), shown in this example and mentioned in How to Use Key Bindings. JFrame f = new JFrame("Example"); Action accept = new AbstractAction("Accept") { @Override public void actionPerformed(ActionEvent e) { // handle accept }

Java Swing: Show pressed button when using corresponding keyboard button

廉价感情. 提交于 2019-12-07 06:01:16
问题 I'm making a program in Java, using Swing, with a GUI that contains arrow keys. The arrow keys correspond to the arrow keys on the keyboard. When I press the up arrow key on the keyboard, I'd like the up arrow key on the GUI to show up as being pressed. Until I release the arrow key, it should show it is still being pressed, and when released it should also release. A snippet of my code so far (only for the Up button), which I think is totally wrong in the show being pressed category: ... if

How to create a binding for NSApp.dockTile's

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:27:14
In IB it is easy to bind a label or text field to some controller's keyPath. The NSDockTile (available via [[NSApp dockTile] setBadgeLabel:@"123"]) doesn't appear in IB, and I cannot figure out how to programmatically bind its "badgeLabel" property like you might bind a label/textfield/table column. Any ideas? NSDockTile doesn't have any bindings, so your controller will have to update the dock tile manually. You could do this using KVO which would have the same effect as binding it. Create a context as a global: static void* MyContext=(void*)@"MyContext"; Then, in your init method:

Multiple-line cursor movements in XCode

南笙酒味 提交于 2019-12-06 12:20:05
I'd like to map a key to move the cursor in the XCode up by ten lines. Of course, I want another one to move down too. The key mapping would ideally be something like 'Control-Alt-P'. Is there a way to achieve this in XCode without resorting to Automator? Ashley has the answer below, the formatting was a little different as the property list is in XML format. In summary, added an entry in the following format to the 'text' section of *.pbxkeys in ~/Library/Application Support/Xcode/Key Bindings/: <key>^~p</key> <array> <string>moveUp:</string> <string>moveUp:</string> </array> Ashley Clark You

Can I create a KeyBinding for a sequence of keys in WPF?

假装没事ソ 提交于 2019-12-06 10:41:28
问题 Is it possible to define key bindings in WPF for a sequence of key presses like the shortcuts in Visual Studio e.g. Ctrl + R , Ctrl + A is run all tests in current solution As far as I can see I can only bind single key combinations like Ctrl + S using the element. Can I bind sequences using this or will I have to manually handle the key presses to do this? 回答1: You need to create your own InputGesture, by overriding the Matches method. Something like that: public class MultiInputGesture :

Keyboard Actionlistener

六眼飞鱼酱① 提交于 2019-12-06 09:57:27
问题 I am trying to make a space ship (PlayerShip.gif) in my game move left, right, up, and down when the coresponding keys are pressed. I know i need an keyboardListener but im having issues figuring out where it goes and how it is actually implimented. my code is as follows. public class GamePanel extends JPanel implements KeyListener { Timer timer1; Timer timer2; ArrayList<Ships> ship; int x; int y; double speed; int size; int shipxCoord; int shipyCoord; int shipHeight; int shipWidth; int

Tkinter keybinding for Control-Shift-Tab

佐手、 提交于 2019-12-06 06:05:09
What's the key-binding for Control-Shift-Tab? I've tried lots of things and nothing seems to work. I'm already aware of tkinter.ttk.Notebook.enable_traversal. If you know of a handler for tabs being activated, that would suffice, too. Armin The general format for representing an event is: <[event modifier(s)-]...event type [-event detail]>. For key-binding Ctrl+Shift+Tab the format would be: 'Control-Shift-KeyPress-Tab'. In this case the event modifiers would be: Control- Shift-, the event type: Keypress, and the event detail: -Tab The following code (in python 2.7.6) should make it clear: