Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1024565 // imageSurfaceOnHover

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (16903L/106K).

1  
// onHover is called with null value when mouse moves outside of image surface
2  
// onHover receives image coordinates
3  
svoid imageSurfaceOnHover(ImageSurface is, VF1<Pt> onHover) {
4  
  if (is == null || onHover == null) ret;
5  
  swing {
6  
    MouseAdapter ma = new MouseAdapter {
7  
      public void mouseMoved(MouseEvent e) { pick(e); }
8  
      public void mouseEntered(MouseEvent e) { pick(e); }
9  
      public void mouseExited(MouseEvent e) { pick(null); }
10  
      
11  
      void pick(MouseEvent e) pcall {
12  
        callF(onHover, e == null ? (Pt) null : is.pointFromEvent(e));
13  
      }
14  
    };
15  
    is.addMouseMotionListener(ma);
16  
    is.addMouseListener(ma);
17  
  }
18  
}
19  
20  
svoid imageSurfaceOnHover(ImageSurface is, IVF1<Pt> onHover) {
21  
  imageSurfaceOnHover(is, toVF1(onHover));
22  
}

Author comment

Began life as a copy of #1024564

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024565
Snippet name: imageSurfaceOnHover
Eternal ID of this version: #1024565/4
Text MD5: 68369fbd8f6bcf3bc42d63e677da116d
Transpilation MD5: 9a3f38911f944e2daa6133404f604aa9
Author: stefan
Category: javax / image analysis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-14 20:18:31
Source code size: 775 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 198 / 304
Version history: 3 change(s)
Referenced in: [show references]