diff --git a/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java b/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java index 67520d2d7d..c58ae3cad2 100644 --- a/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java +++ b/Mage.Client/src/main/java/mage/client/components/KeyboundButton.java @@ -15,7 +15,7 @@ public class KeyboundButton extends JButton { private final String text; private static final Font keyFont = new Font(Font.SANS_SERIF, Font.BOLD, 13); - private boolean pressing = false; + private boolean tinting = false; public KeyboundButton(String key) { text = PreferencesDialog.getCachedKeyText(key); @@ -27,11 +27,11 @@ public class KeyboundButton extends JButton { Graphics sg = g.create(); try { ui.update(sg, this); - if (pressing) { + if (tinting) { sg.setColor(new Color(0, 0, 0, 32)); sg.fillRoundRect(2, 2, getWidth() - 4 , getHeight() - 4, 6, 6); } - sg.setColor(pressing ? Color.lightGray : Color.white); + sg.setColor(tinting ? Color.lightGray : Color.white); sg.setFont(keyFont); int textWidth = sg.getFontMetrics(keyFont).stringWidth(text); @@ -44,8 +44,8 @@ public class KeyboundButton extends JButton { } } - public void setPressing(boolean pressing) { - this.pressing = pressing; + public void setTint(boolean tinting) { + this.tinting = tinting; repaint(); } diff --git a/Mage.Client/src/main/java/mage/client/game/FirstButtonMousePressedAction.java b/Mage.Client/src/main/java/mage/client/game/FirstButtonMousePressedAction.java index 8cee1944af..881a6b1f13 100644 --- a/Mage.Client/src/main/java/mage/client/game/FirstButtonMousePressedAction.java +++ b/Mage.Client/src/main/java/mage/client/game/FirstButtonMousePressedAction.java @@ -9,6 +9,7 @@ import java.util.function.Consumer; public class FirstButtonMousePressedAction extends MouseAdapter { private final Consumer callback; + private boolean pressed = false; private boolean inside = false; public FirstButtonMousePressedAction(Consumer callback) { @@ -17,17 +18,19 @@ public class FirstButtonMousePressedAction extends MouseAdapter { @Override public void mousePressed(MouseEvent e) { + pressed = true; if (e.getSource() instanceof KeyboundButton) { KeyboundButton button = (KeyboundButton) e.getSource(); - button.setPressing(true); + button.setTint(true); } } @Override public void mouseReleased(MouseEvent e) { + pressed = false; if (e.getSource() instanceof KeyboundButton) { KeyboundButton button = (KeyboundButton) e.getSource(); - button.setPressing(false); + button.setTint(false); } if (e.getButton() == MouseEvent.BUTTON1 && inside) { callback.accept(e); @@ -37,11 +40,19 @@ public class FirstButtonMousePressedAction extends MouseAdapter { @Override public void mouseEntered(MouseEvent e) { inside = true; + if (pressed && e.getSource() instanceof KeyboundButton) { + KeyboundButton button = (KeyboundButton) e.getSource(); + button.setTint(true); + } } @Override public void mouseExited(MouseEvent e) { inside = false; + if (e.getSource() instanceof KeyboundButton) { + KeyboundButton button = (KeyboundButton) e.getSource(); + button.setTint(false); + } } }