Libraryless. Click here for Pure Java version (5566L/31K).
// show popup menu on right click only when a condition is met svoid makePopupMenuConditional(JComponent c, F0<Bool> condition) { if (c != null && condition != null) swing { componentPopupMenu_Adapter adapter = firstInstanceOf(c.getMouseListeners(), componentPopupMenu_Adapter); c.removeMouseListener(adapter); c.addMouseListener(new MouseAdapter { public void mousePressed(MouseEvent e) { if (!callF(condition)) adapter.mousePressed(e); } public void mouseReleased(MouseEvent e) { if (!callF(condition)) adapter.mouseReleased(e); } }); } }
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019927 |
Snippet name: | makePopupMenuConditional |
Eternal ID of this version: | #1019927/4 |
Text MD5: | 460281e194aeac348f2a0383b30da2c2 |
Transpilation MD5: | 2b3e15bdb92d9cc90d7cc298a1fa7932 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-24 16:49:32 |
Source code size: | 614 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 353 / 460 |
Version history: | 3 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1021793 - findComponentPopupMenuListener_gen |