1 | // combines mousePressed, mouseDragged and mouseReleased |
2 | // left button only |
3 | // f : voidfunc(Pt) - point can be null, then mouse was released |
4 | static void imageSurfaceOnMouseDrag(final ImageSurface is, final O f) { |
5 | swing { |
6 | MouseAdapter ma = new MouseAdapter { |
7 | bool in; |
8 | |
9 | public void mouseDragged(MouseEvent e) { |
10 | if (!in) ret; |
11 | pcallF(f, is.pointFromEvent(e)); |
12 | } |
13 | |
14 | public void mousePressed(MouseEvent e) { |
15 | if (e.getButton() != MouseEvent.BUTTON1) ret; |
16 | in = true; |
17 | pcallF(f, is.pointFromEvent(e)); |
18 | } |
19 | |
20 | public void mouseReleased(MouseEvent e) { |
21 | if (e.getButton() != MouseEvent.BUTTON1) ret; |
22 | if (!in) ret; |
23 | in = false; |
24 | pcallF(f, (Pt) null); |
25 | } |
26 | }; |
27 | is.addMouseMotionListener(ma); |
28 | is.addMouseListener(ma); |
29 | } |
30 | } |
Began life as a copy of #1005948
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018716 |
Snippet name: | imageSurfaceOnMouseDrag |
Eternal ID of this version: | #1018716/1 |
Text MD5: | 6a39a1d6935c20291c117686ec4012a8 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-11 20:50:01 |
Source code size: | 871 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 263 / 296 |
Referenced in: | [show references] |