key-bindings

Override the enter key, but keep default behavior for other keys in a wpf datagrid

喜你入骨 提交于 2019-12-06 05:27:28
问题 It really bothers me that the pressing the enter key in a Datagrid moves the selection down one item, I'd like to be able to decide what it does in a normal keydown event. So what I did was create a new class that inherits DataGrid and override the OnKeyDown event and use that as my datagrid. This creates a whole new set of problems, since I apparently have to rewrite all the other keypresses (arrow key navigation, shift+arrow key selection, pgup/pgdn, etc..). I've been trying to hack it, but

Get file path + file name in a keybindings file in Sublime Text 2

送分小仙女□ 提交于 2019-12-06 03:45:21
I'm trying to get the path of the current file + the file's name (without extension) in a Key Binding file in Sublime Text 2. $file_path or ${file_path} are both not working. The reason is that I want to execute an *.exe file, which was built before (but don't want to both build and execute in one step). Any ideas? Greetz you may try the sublime-snippet , this is my code: #filename: filename.sublime-snippet <snippet> <content><![CDATA[$TM_FILENAME]]></content> <!-- Optional: Tab trigger to activate the snippet --> <tabTrigger>fn</tabTrigger> <!-- Optional: Scope the tab trigger will be active

Custom keyboard shortcut in java

半腔热情 提交于 2019-12-06 01:59:07
I am developing a java swing application. I want to add a keyboard shortcut say CTRL + H . This should perform the same action performed by jButton1 when clicked. This shortcut should behave in the same way even when jButton1 is not focused. I tried with KeyEventDispatcher, but it doesn't seem to be working for me. Is there any other way? Chan Ok - First I don't think there is a way to set application wide shortcuts in Java Swing(Refer this question ). But for a component it is possible. You have to use a create an Action for the KeyStroke . But for Windows I found this library very helpful .

Java: How to remove default KeyStrokes from any JComponent?

浪子不回头ぞ 提交于 2019-12-06 01:28:19
问题 I want to control which keystroke belong to which Jcomponent . I even want to get how to remove the default keystrokes associated with a Jcomponent and replace them with other favourite keystrokes. I followed this oracle tutorial, it gives an example with JButton, I tried it and it works fine, but when I try it with JComboBox it doesn’t work! What exactly I tried is removing the SPACE key, that is prevent the JComponent from responding to SPACE presses I used this code to remove the SPACE key

Override VK_Tab Focus action

余生长醉 提交于 2019-12-05 23:30:47
Good Day! I am tying to add keyevent listener to jTextField so that if the user pressed the tab key, the caret position will go to the end of the text inside the jtextField, here is my code: private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) { if(evt.getKeyCode()==KeyEvent.VK_TAB){ evt.consume(); jTextField1.setCaretPosition(jTextField1.getText().length()); } } But it doesn't work. How can i make this happen? Hovercraft Full Of Eels One way is to: First of all, don't use a KeyListener since this is a Swing application, and you shouldn't use KeyListeners in Swing apps if it can be

Create a single key-binding that fires a command every time control is pressed with any number and then passes the number as a parameter?

这一生的挚爱 提交于 2019-12-05 20:52:34
问题 I need to create hot-keys for every control + number combination and would prefer not to have create ten commands. Is there any way to do this? 回答1: If I understand your question, you have a single command, say MyCommand , and you want to fire it if the user presses CTRL+0 through CTRL+9, and give the command a different parameter for each combination. In that case, just create 10 key bindings in your window, all bound to MyCommand , and give them a parameter: <Window.InputBindings>

Java Swing: Do something while the key is being pressed

安稳与你 提交于 2019-12-05 15:17:35
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 implemented way to do it: public abstract class MyKeyAdapter extends KeyAdapter{ private boolean isPressed

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

≯℡__Kan透↙ 提交于 2019-12-05 13:34:37
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) ? trashgod 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 } }; private JButton b = new JButton(accept); ... f.getRootPane().setDefaultButton(b); Add an

remap default keybinding in tkinter

不问归期 提交于 2019-12-05 11:52:23
I am adding a keybinding to my root window (a Tk() instance, which contains a Text widget) : root.bind("Control-o", setconnpanelopen) The problem is that it seems that control-o is bound by default to "insert newline", so that my procedure fires, but it also inserts a newline! This happens even if I put a return 'break' at its end - so it fires before, so it seems. 1) how can I remap this behaviour? 2) I didnt find anywhere a list of the default keybindings of the text widgets - they are available somewhere? You want to read up on "bindtags" -- tkinter's binding mechanism. Widgets have a set

How to disable Ctrl-Click in VS Code

心不动则不痛 提交于 2019-12-05 11:45:49
问题 Wanna know if it's possible to remove the key bind on Ctrl-Click for the goToDefinition ( F12 ) editor action... This is so annoying, every time i try to Ctrl + C / V it trigger and go to the definition cause i'm holding Ctrl while I'm highlighting the code with my mouse... May be it's just a bad habits I got but god I need to turn this off please. I have search for it on google but all y can change is the F12 key bind for goToDefinition which is not what I want. Thanks WoofWoofDude ---