Libraryless. Click here for Pure Java version (11200L/63K).
1 | static AutoCloseable tempGlobalPopupMenu(IVF2<Component, JPopupMenu> fillMenu, double delay default 0.1) { |
2 | ret fillMenu == null ?: tempAddPopupButtonListener(evt -> { |
3 | var c = evt.getComponent(); |
4 | if (c == null) ret; // It's a tray icon popup |
5 | var c2 = SwingUtilities.getDeepestComponentAt(c, evt.getX(), evt.getY()); |
6 | var p = ptInComponentFromEvent(evt); |
7 | var p2 = translateLocationBetweenComponents(p, c2); |
8 | |
9 | awtLater(delay, r { |
10 | var menu = currentPopupMenu(); |
11 | |
12 | print("Pimping popup menu " + menu); |
13 | new PopupMenuMaker maker; |
14 | maker.ptInComponent(p2); |
15 | maker.event(evt).existingMenu(menu).fillMenu( |
16 | _menu -> fillMenu.get(c2, _menu)).run(); |
17 | }); |
18 | }); |
19 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034620 |
Snippet name: | tempGlobalPopupMenu - popup menu items for any component on screen |
Eternal ID of this version: | #1034620/18 |
Text MD5: | 649fffea9f835c8fe82e498b52105fc4 |
Transpilation MD5: | 28cdf5ee88d10a9ace9315febf13fa01 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-01-31 14:57:55 |
Source code size: | 741 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 244 / 402 |
Version history: | 17 change(s) |
Referenced in: | [show references] |