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

17
LINES

< > BotCompany Repo | #1016818 // handleCtrlTab_dev

JavaX fragment (include)

static void handleCtrlTab_dev(final JComponent c) {
  swing {
    print("handleCtrlTab_dev: c=" + c);
    S name1 = "ctrl+tab pressed", name2 = "ctrl+tab released";
    
    KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB");
    KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl shift TAB");
    
    c.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, setMinus(c.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS), ctrlTab));
    c.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, setMinus(c.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS), ctrlShiftTab));
    
    c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_MASK, false), name1);
    c.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_MASK, true), name2);
    c.getActionMap().put(name1, abstractAction(name1, r { print("ctrl+tab yo") }));
    c.getActionMap().put(name2, abstractAction(name2, r { print("ctrl+tab no more") }));
  }
}

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: 419 / 437
Version history: 12 change(s)
Referenced in: [show references]