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

20
LINES

< > BotCompany Repo | #1036223 // onHover

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

Transpiled version (9227L) is out of date.

static <A extends JComponent> A onHover(IVF1<Pt> action, A c) {
  if (c != null && action != null) swing {
    MouseAdapter ma = new MouseAdapter {
      public void mouseMoved(MouseEvent e) { pick(e); }
      public void mouseEntered(MouseEvent e) { pick(e); }
      public void mouseExited(MouseEvent e) { pick(null); }
      
      void pick(MouseEvent e) pcall {
        action.get(ptFromEvent(e));
      }
    };
    c.addMouseMotionListener(ma);
    c.addMouseListener(ma);
  }
  ret c;
}

static <A extends JComponent> A onHover(A c, IVF1<Pt> action) {
  ret onHover(action, c);
}

Author comment

Began life as a copy of #1024565

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036223
Snippet name: onHover
Eternal ID of this version: #1036223/5
Text MD5: 36ffece50d3a51ba70d9677bc319edce
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-25 22:18:53
Source code size: 602 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 168 / 209
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)