Browse Source

Merge branch 'feature/10.0' of https://code.fineres.com/scm/~hades/design into feature/10.0

persist/11.0
hades 4 years ago
parent
commit
d1de8589f1
  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