1 | sclass componentPopupMenu_Maker {
|
2 | new L menuMakers; |
3 | } |
4 | |
5 | static Map<JComponent, componentPopupMenu_Maker> componentPopupMenu_map = new WeakHashMap; |
6 | |
7 | static new ThreadLocal<MouseEvent> componentPopupMenu_mouseEvent; |
8 | |
9 | // menuMaker = voidfunc(JPopupMenu) |
10 | static void componentPopupMenu(final JComponent component, fO menuMaker) {
|
11 | awtIfNecessary {
|
12 | componentPopupMenu_Maker maker = componentPopupMenu_map.get(component); |
13 | if (maker == null) {
|
14 | componentPopupMenu_map.put(component, maker = new componentPopupMenu_Maker); |
15 | final componentPopupMenu_Maker _maker = maker; |
16 | component.addMouseListener(new MouseAdapter {
|
17 | public void mousePressed(MouseEvent e) { displayMenu(e); }
|
18 | public void mouseReleased(MouseEvent e) { displayMenu(e); }
|
19 | |
20 | void displayMenu(MouseEvent e) {
|
21 | if (e.isPopupTrigger()) {
|
22 | new JPopupMenu menu; |
23 | int emptyCount = menu.getComponentCount(); |
24 | |
25 | componentPopupMenu_mouseEvent.set(e); |
26 | for (O menuMaker : _maker.menuMakers) |
27 | pcallF(menuMaker, menu); |
28 | |
29 | // show menu if any items in it |
30 | if (menu.getComponentCount() != emptyCount) |
31 | menu.show(e.getComponent(), e.getX(), e.getY()); |
32 | } |
33 | } |
34 | }); |
35 | } |
36 | maker.menuMakers.add(menuMaker); |
37 | } |
38 | } |
Began life as a copy of #1005719
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1007780 |
| Snippet name: | componentPopupMenu backup |
| Eternal ID of this version: | #1007780/1 |
| Text MD5: | 1aea1a671e05d3353c8fd91229ef5930 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-04-06 11:58:42 |
| Source code size: | 1387 bytes / 38 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 804 / 778 |
| Referenced in: | [show references] |