reevaluate cursor hover after clicking on a card while playing a match. this enables tapping multiple lands without moving the mouse

This commit is contained in:
myk
2013-02-14 19:34:31 +00:00
parent c7018e162b
commit dc2e9a1ca4
2 changed files with 20 additions and 25 deletions

View File

@@ -69,13 +69,13 @@ public class ToolTipListener
*/ */
private void phantomMouseMoved(Component component) private void phantomMouseMoved(Component component)
{ {
if (component == null) return; if (null == component) {
return;
// Mouse is in the bounds of the component, generate phantom }
// mouseMoved event for the ToolTipManager
// mouse is in the bounds of the component, generate phantom
// mouseMoved event for the ToolTipManager
Point mouseLocation = component.getMousePosition(); Point mouseLocation = component.getMousePosition();
if (mouseLocation != null) if (mouseLocation != null)
{ {
MouseEvent phantom = new MouseEvent( MouseEvent phantom = new MouseEvent(
@@ -92,37 +92,32 @@ public class ToolTipListener
} }
} }
// Implement ComponentListener // implement ComponentListener
public void componentMoved(ComponentEvent e) public void componentMoved(ComponentEvent e)
{ {
Component component = e.getComponent(); phantomMouseMoved(e.getComponent());
phantomMouseMoved( component );
} }
public void componentResized(ComponentEvent e) public void componentResized(ComponentEvent e)
{ {
Component component = e.getComponent(); phantomMouseMoved(e.getComponent());
phantomMouseMoved( component );
} }
public void componentHidden(ComponentEvent e) {} public void componentHidden(ComponentEvent e) { }
public void componentShown(ComponentEvent e) {} public void componentShown(ComponentEvent e) { }
// Implement MouseWheelListener // implement MouseWheelListener
public void mouseWheelMoved(MouseWheelEvent e) public void mouseWheelMoved(MouseWheelEvent e)
{ {
JScrollPane scrollPane = (JScrollPane)e.getSource(); JScrollPane scrollPane = (JScrollPane)e.getSource();
Component component = scrollPane.getViewport().getView(); phantomMouseMoved(scrollPane.getViewport().getView());
phantomMouseMoved( component );
} }
// Implement AdjustmentListener // implement AdjustmentListener
public void adjustmentValueChanged(AdjustmentEvent e) public void adjustmentValueChanged(AdjustmentEvent e)
{ {
JScrollBar scrollBar = (JScrollBar)e.getSource(); JScrollBar scrollBar = (JScrollBar)e.getSource();
JScrollPane scrollPane = (JScrollPane)scrollBar.getParent(); JScrollPane scrollPane = (JScrollPane)scrollBar.getParent();
Component component = scrollPane.getViewport().getView(); phantomMouseMoved(scrollPane.getViewport().getView());
phantomMouseMoved( component );
} }
} }

View File

@@ -89,7 +89,7 @@ public abstract class CardPanelContainer extends JPanel {
this.setOpaque(true); this.setOpaque(true);
this.addMouseMotionListener(new MouseMotionListener() { final MouseMotionListener mml = new MouseMotionListener() {
@Override @Override
public void mouseDragged(final MouseEvent evt) { public void mouseDragged(final MouseEvent evt) {
if (!CardPanelContainer.this.dragEnabled) { if (!CardPanelContainer.this.dragEnabled) {
@@ -148,7 +148,8 @@ public abstract class CardPanelContainer extends JPanel {
// System.err.format("%d %d over %s%n", evt.getX(), evt.getY(), hitPanel == null ? null : hitPanel.getCard().getName()); // System.err.format("%d %d over %s%n", evt.getX(), evt.getY(), hitPanel == null ? null : hitPanel.getCard().getName());
} }
}); };
this.addMouseMotionListener(mml);
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
private final boolean[] buttonsDown = new boolean[4]; private final boolean[] buttonsDown = new boolean[4];
@@ -202,6 +203,9 @@ public abstract class CardPanelContainer extends JPanel {
} else if (SwingUtilities.isMiddleMouseButton(evt)) { } else if (SwingUtilities.isMiddleMouseButton(evt)) {
CardPanelContainer.this.mouseMiddleClicked(panel, evt); CardPanelContainer.this.mouseMiddleClicked(panel, evt);
} }
} else {
// reeval cursor hover
mml.mouseMoved(evt);
} }
} }
@@ -209,10 +213,6 @@ public abstract class CardPanelContainer extends JPanel {
public void mouseExited(final MouseEvent evt) { public void mouseExited(final MouseEvent evt) {
CardPanelContainer.this.mouseOutPanel(evt); CardPanelContainer.this.mouseOutPanel(evt);
} }
@Override
public void mouseEntered(final MouseEvent e) {
}
}); });
} }