Browse Source

Pull request #2207: REPORT-37821 frm绝对布局框选多个组件有问题 合丢了

Merge in DESIGN/design from ~HADES/design:bugfix/10.0 to bugfix/10.0

* commit 'e93ef2b31d4441b785a2c1cc4ee2187923d61ad3':
  REPORT-37821 frm绝对布局框选多个组件有问题 合丢了
bugfix/10.0
Hades 4 years ago
parent
commit
a1431a7c62
  1. 12
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

12
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -210,6 +210,7 @@ public class EditingMouseListener extends MouseInputAdapter {
*/ */
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
MouseEvent transEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton()); MouseEvent transEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
MouseEvent clickEvent = new MouseEvent(e.getComponent(), MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
int oldX = e.getX(); int oldX = e.getX();
int oldY = e.getY(); int oldY = e.getY();
offsetEventPoint(e); offsetEventPoint(e);
@ -234,14 +235,21 @@ public class EditingMouseListener extends MouseInputAdapter {
lastPressEvent = null; lastPressEvent = null;
lastXCreator = null; lastXCreator = null;
e.translatePoint(oldX - e.getX(), oldY - e.getY()); e.translatePoint(oldX - e.getX(), oldY - e.getY());
if (pressX != oldX || pressY != oldY) { if (isAutoFire(transEvent, clickEvent)) {
// click只有在mouseReleased和mousePressed前后x/y坐标相等时才会被触发在mouseReleased之后 // click只有在mouseReleased和mousePressed前后x/y坐标相等时才会被触发在mouseReleased之后
// 但是当使用者来回点击切换时 存在mouseReleased和mousePressed前后x/y坐标不相等的情况 即鼠标按下去的位置和鼠标释放的位置不相等 存在偏移 // 但是当使用者来回点击切换时 存在mouseReleased和mousePressed前后x/y坐标不相等的情况 即鼠标按下去的位置和鼠标释放的位置不相等 存在偏移
// 当这种偏移很小时 看起来就好像是点击了 实际上是手抖了或者鼠标轻微滑动了 所以这里对这种情况要有容错处理 // 当这种偏移很小时 看起来就好像是点击了 实际上是手抖了或者鼠标轻微滑动了 所以这里对这种情况要有容错处理
mouseClicked(transEvent); mouseClicked(clickEvent);
} }
} }
private boolean isAutoFire(MouseEvent transEvent, MouseEvent clickEvent ) {
offsetEventPoint(transEvent);
XCreator xCreator = designer.getComponentAt(transEvent);
return (pressX != clickEvent.getX() || pressY != clickEvent.getY())
&& xCreator != null && xCreator.acceptType(XCardSwitchButton.class);
}
private void mouseDraggingRelease(MouseEvent e) { private void mouseDraggingRelease(MouseEvent e) {
// 当前鼠标所在的组件 // 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY()); XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY());

Loading…
Cancel
Save