1 | static AutoCloseable tempOnKeyPressed(final int keyCode, final Runnable r, final JComponent a) { |
2 | if (a == null) null; |
3 | final KeyAdapter listener = new { |
4 | @Override |
5 | public void keyPressed(KeyEvent e) { |
6 | ifdef tempOnKeyPressed_debug |
7 | print("key code: " + e.getKeyCode()); |
8 | endifdef |
9 | if (simplifyKeyCode(e.getKeyCode()) == keyCode && e.getModifiers() == 0) |
10 | pcallF(r); |
11 | } |
12 | }; |
13 | swing { a.addKeyListener(listener); } |
14 | ifdef tempOnKeyPressed_debug |
15 | print("key listener installed"); |
16 | endifdef |
17 | ret autoCloseable { |
18 | swing { a.removeKeyListener(listener); } |
19 | ifdef tempOnKeyPressed_debug |
20 | print("key listener removed"); |
21 | endifdef |
22 | }; |
23 | } |
Began life as a copy of #1019019
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019022 |
Snippet name: | tempOnKeyPressed |
Eternal ID of this version: | #1019022/6 |
Text MD5: | 6ebbcf27c5427c066548e89df92df777 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-12 04:01:34 |
Source code size: | 713 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 436 / 499 |
Version history: | 5 change(s) |
Referenced in: | [show references] |