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

11
LINES

< > BotCompany Repo | #1020885 // tempAddGlobalMouseListener - add a global AWT mouse event listener (just clicks, not motion)

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

Libraryless. Click here for Pure Java version (5048L/28K).

static AutoCloseable tempAddGlobalMouseListener(IVF1<MouseEvent> onEvent) {
  AWTEventListener l = new AWTEventListener {
    public void eventDispatched(AWTEvent evt) {
      if (evt cast MouseEvent)
        pcallF_typed(onEvent, evt);
    }
  };
  
  Toolkit.getDefaultToolkit().addAWTEventListener(l, AWTEvent.MOUSE_EVENT_MASK);
  ret -> Toolkit.getDefaultToolkit().removeAWTEventListener(l);
}

Author comment

Began life as a copy of #1003983

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020885
Snippet name: tempAddGlobalMouseListener - add a global AWT mouse event listener (just clicks, not motion)
Eternal ID of this version: #1020885/9
Text MD5: 0b09e764a8a1599f889b2f7aac5ad692
Transpilation MD5: 76e876547f4e36320d63e3e8ddc17b55
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-24 18:22:13
Source code size: 407 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 350 / 476
Version history: 8 change(s)
Referenced in: [show references]