Browse Source

REPORT-5489 @Plough:9.0设计器交互验收=>列表面板中,点击空白区域,不选中最后一项

master
plough 7 years ago
parent
commit
fa6105a7b4
  1. 19
      designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  2. 30
      designer_base/src/com/fr/design/gui/ilist/UINameEdList.java

19
designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java

@ -37,10 +37,7 @@ import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
@ -805,6 +802,20 @@ public abstract class UIListControlPane extends UIControlPane {
evt.getY() - 1);
}
@Override
public void mouseClicked(MouseEvent e) {
JList list = (JList) e.getSource();
if (list.locationToIndex(e.getPoint()) == -1 && !e.isShiftDown()
&& !isMenuShortcutKeyDown(e)) {
list.clearSelection();
}
}
private boolean isMenuShortcutKeyDown(InputEvent event) {
return (event.getModifiers() & Toolkit.getDefaultToolkit()
.getMenuShortcutKeyMask()) != 0;
}
@Override
public void mouseMoved(MouseEvent e) {

30
designer_base/src/com/fr/design/gui/ilist/UINameEdList.java

@ -12,10 +12,7 @@ import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Vector;
@ -352,6 +349,17 @@ public class UINameEdList extends UIList implements CellEditorListener {
repaint(cellRect);
}
@Override
public int locationToIndex(Point location) {
int index = super.locationToIndex(location);
if (index != -1 && !getCellBounds(index, index).contains(location)) {
return -1;
}
else {
return index;
}
}
/**
* 主函数
*
@ -375,6 +383,20 @@ public class UINameEdList extends UIList implements CellEditorListener {
list.editItemAt(list.getSelectedIndex());
}
}
@Override
public void mouseClicked(MouseEvent e) {
JList list = (JList) e.getSource();
if (list.locationToIndex(e.getPoint()) == -1 && !e.isShiftDown()
&& !isMenuShortcutKeyDown(e)) {
list.clearSelection();
}
}
private boolean isMenuShortcutKeyDown(InputEvent event) {
return (event.getModifiers() & Toolkit.getDefaultToolkit()
.getMenuShortcutKeyMask()) != 0;
}
})
;

Loading…
Cancel
Save