From d0e7f6b40530513d105ec457a8fdd9ed29474544 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 17 Nov 2016 17:50:47 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-817=20=E6=94=B9=E4=B8=AA=E5=86=99?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/style/AbstractPopBox.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/designer_base/src/com/fr/design/style/AbstractPopBox.java b/designer_base/src/com/fr/design/style/AbstractPopBox.java index 6e8d8a212..bc07444c4 100644 --- a/designer_base/src/com/fr/design/style/AbstractPopBox.java +++ b/designer_base/src/com/fr/design/style/AbstractPopBox.java @@ -49,7 +49,7 @@ public abstract class AbstractPopBox extends JPanel { } } }; - + private void showPopupMenu() { if (selectPopupWindow != null && selectPopupWindow.isVisible()) { hidePopupMenu(); @@ -96,13 +96,14 @@ public abstract class AbstractPopBox extends JPanel { } private void mouseClick(MouseEvent evt) { - int x = evt.getLocationOnScreen().x; - int y = evt.getLocationOnScreen().y; - Rectangle popBoxRect = AbstractPopBox.this.getBounds(); - Rectangle rectangle = this.getControlWindow().getBounds(); - boolean b1 = x < rectangle.x || x > rectangle.x + rectangle.width; - boolean b2 = y < rectangle.y - popBoxRect.height || y > rectangle.y + rectangle.height; - if (b1 || b2) { + Point point = new Point((int) (evt.getLocationOnScreen().getX()), (int) evt.getLocationOnScreen().getY()); + Dimension d = AbstractPopBox.this.getSize(); + Point p = AbstractPopBox.this.getLocationOnScreen(); + Dimension popBoxD = this.getControlWindow().getSize(); + Point popBoxP = this.getControlWindow().getLocation(); + Rectangle rect = new Rectangle(p, d); + Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); + if (!rect.contains(point) && !popBoxRect.contains(point)) { this.hidePopupMenu(); } }