mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
GUI, game: fixed game error in choose ability dialog on using CTRL and mouse wheel (#13186)
This commit is contained in:
parent
2853cf1b99
commit
216826b513
1 changed files with 12 additions and 13 deletions
|
|
@ -152,7 +152,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
setBackgroundPainter(mwPanelPainter);
|
setBackgroundPainter(mwPanelPainter);
|
||||||
|
|
||||||
title = new ColorPane();
|
title = new ColorPane();
|
||||||
title.setFont(new Font("Times New Roman", 1, sizeMod(15)));
|
title.setFont(new Font("Times New Roman", Font.BOLD, sizeMod(15)));
|
||||||
title.setEditable(false);
|
title.setEditable(false);
|
||||||
title.setFocusCycleRoot(false);
|
title.setFocusCycleRoot(false);
|
||||||
title.setOpaque(false);
|
title.setOpaque(false);
|
||||||
|
|
@ -186,11 +186,12 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
rows.addMouseListener(new MouseAdapter() {
|
rows.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent evt) {
|
public void mousePressed(MouseEvent evt) {
|
||||||
if (SwingUtilities.isLeftMouseButton(evt)) {
|
if (SwingUtilities.isLeftMouseButton(evt) && !rows.isSelectionEmpty()) {
|
||||||
objectMouseClicked(evt);
|
objectMouseClicked(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rows.setSelectedIndex(0);
|
rows.setSelectedIndex(0);
|
||||||
rows.setFont(new Font("Times New Roman", 1, sizeMod(17)));
|
rows.setFont(new Font("Times New Roman", 1, sizeMod(17)));
|
||||||
rows.setBorder(BorderFactory.createEmptyBorder());
|
rows.setBorder(BorderFactory.createEmptyBorder());
|
||||||
|
|
@ -233,19 +234,17 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
int notches = e.getWheelRotation();
|
int direction = e.getWheelRotation() < 0 ? -1 : +1;
|
||||||
int index = rows.getSelectedIndex();
|
int index = rows.getSelectedIndex() + direction;
|
||||||
|
if (index < 0) {
|
||||||
|
index = 0;
|
||||||
|
} else if (index >= choices.size()) {
|
||||||
|
index = choices.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (notches < 0) {
|
rows.setSelectedIndex(index);
|
||||||
if (index > 0) {
|
|
||||||
rows.setSelectedIndex(index - 1);
|
|
||||||
rows.repaint();
|
rows.repaint();
|
||||||
}
|
}
|
||||||
} else if (index < choices.size() - 1) {
|
|
||||||
rows.setSelectedIndex(index + 1);
|
|
||||||
rows.repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void objectMouseClicked(MouseEvent event) {
|
private void objectMouseClicked(MouseEvent event) {
|
||||||
int index = rows.getSelectedIndex();
|
int index = rows.getSelectedIndex();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue