Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1016818 // handleCtrlTab_dev

JavaX fragment (include)

1  
static void handleCtrlTab_dev(final JComponent c) {
2  
  swing {
3  
    print("handleCtrlTab_dev: c=" + c);
4  
    S name1 = "ctrl+tab pressed", name2 = "ctrl+tab released";
5  
    
6  
    KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB");
7  
    KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl shift TAB");
8  
    
9  
    c.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, setMinus(c.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS), ctrlTab));
10  
    c.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, setMinus(c.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS), ctrlShiftTab));
11  
    
12  
    c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_MASK, false), name1);
13  
    c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_MASK, true), name2);
14  
    c.getActionMap().put(name1, abstractAction(name1, r { print("ctrl+tab yo") }));
15  
    c.getActionMap().put(name2, abstractAction(name2, r { print("ctrl+tab no more") }));
16  
  }
17  
}

Author comment

Began life as a copy of #1016090

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016818
Snippet name: handleCtrlTab_dev
Eternal ID of this version: #1016818/13
Text MD5: 1e4ae9c4ae9180842f9e8342de225905
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-03 15:45:58
Source code size: 1107 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 420 / 439
Version history: 12 change(s)
Referenced in: [show references]