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

15
LINES

< > BotCompany Repo | #1035242 // mouseEventIsInBorder - did the mouse event happen in the border of a component?

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

Libraryless. Click here for Pure Java version (9186L/51K).

1  
sbool mouseEventIsInBorder(MouseEvent e) swing {
2  
  var c = optCast JComponent(e.getComponent());
3  
  if (c == null) false;
4  
  var border = c.getBorder();
5  
  if (border == null) false;
6  
  Insets insets = border.getBorderInsets(c);
7  
  int x = e.getX(), y = e.getY();
8  
  int w = c.getWidth(), h = c.getHeight();
9  
  bool result = x < insets.left
10  
    || x >= w-insets.right
11  
    || y < insets.top
12  
    || y >= h-insets.bottom;
13  
  printVars ifdef mouseEventIsInBorder_debug("mouseEventIsInBorder " + result, +insets, +w, +h, +x, +y);
14  
  ret result;
15  
}

Author comment

Began life as a copy of #1033465

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035242
Snippet name: mouseEventIsInBorder - did the mouse event happen in the border of a component?
Eternal ID of this version: #1035242/11
Text MD5: dedeb7b0fc6a7a0936704df64981bb1c
Transpilation MD5: 7029e1a51d36f8b78eca082909650495
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-21 03:37:27
Source code size: 546 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 167 / 276
Version history: 10 change(s)
Referenced in: [show references]