Browse Source

REPORT-37289 【10.0.9冒烟】frm模板tab,在设计器内进行多次来回点击切换,发现会偶然的点击失效或卡顿

feature/big-screen
hades 4 years ago
parent
commit
672ef252d4
  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

@ -79,6 +79,9 @@ public class EditingMouseListener extends MouseInputAdapter {
//备份开始拖动的位置和大小
private Rectangle dragBackupBounds;
private int pressX;
private int pressY;
/**
* 获取最小移动距离
*
@ -141,6 +144,8 @@ public class EditingMouseListener extends MouseInputAdapter {
public void mousePressed(MouseEvent e) {
int oldX = e.getX();
int oldY = e.getY();
pressX = oldX;
pressY = oldY;
offsetEventPoint(e);
if (!stopEditing()) {
return;
@ -189,6 +194,7 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param 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());
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
@ -213,6 +219,12 @@ public class EditingMouseListener extends MouseInputAdapter {
lastPressEvent = null;
lastXCreator = null;
e.translatePoint(oldX - e.getX(), oldY - e.getY());
if (pressX != oldX || pressY != oldY) {
// click只有在mouseReleased和mousePressed前后x/y坐标相等时才会被触发在mouseReleased之后
// 但是当使用者来回点击切换时 存在mouseReleased和mousePressed前后x/y坐标不相等的情况 即鼠标按下去的位置和鼠标释放的位置不相等 存在偏移
// 当这种偏移很小时 看起来就好像是点击了 实际上是手抖了或者鼠标轻微滑动了 所以这里对这种情况要有容错处理
mouseClicked(transEvent);
}
}
private void mouseDraggingRelease(MouseEvent e) {

Loading…
Cancel
Save