mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Use FMouseAdapter to make catalog and deck tables more responsive
This commit is contained in:
@@ -27,7 +27,6 @@ import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -64,6 +63,7 @@ import forge.gui.match.controllers.CDetail;
|
||||
import forge.gui.match.controllers.CPicture;
|
||||
import forge.gui.menus.IMenuProvider;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FMouseAdapter;
|
||||
import forge.gui.toolbox.FSkin;
|
||||
import forge.gui.toolbox.itemmanager.ItemManager;
|
||||
import forge.gui.toolbox.itemmanager.SItemManagerIO;
|
||||
@@ -359,27 +359,31 @@ public enum CDeckEditorUI implements ICDoc, IMenuProvider {
|
||||
}
|
||||
};
|
||||
|
||||
catTable.addMouseListener(new MouseAdapter() {
|
||||
catTable.addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (MouseEvent.BUTTON1 == e.getButton() && 2 == e.getClickCount()) { addSelectedCards(false, 1); }
|
||||
else if (MouseEvent.BUTTON3 == e.getButton()) {
|
||||
_ContextMenuBuilder cmb = new _ContextMenuBuilder(e, catTable, deckTable, onAdd);
|
||||
childController.buildAddContextMenu(cmb);
|
||||
cmb.show();
|
||||
}
|
||||
public void onLeftDoubleClick(MouseEvent e) {
|
||||
addSelectedCards(false, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(MouseEvent e) {
|
||||
_ContextMenuBuilder cmb = new _ContextMenuBuilder(e, catTable, deckTable, onAdd);
|
||||
childController.buildAddContextMenu(cmb);
|
||||
cmb.show();
|
||||
}
|
||||
});
|
||||
|
||||
deckTable.addMouseListener(new MouseAdapter() {
|
||||
deckTable.addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (MouseEvent.BUTTON1 == e.getButton() && 2 == e.getClickCount()) { removeSelectedCards(false, 1); }
|
||||
else if (MouseEvent.BUTTON3 == e.getButton()) {
|
||||
_ContextMenuBuilder cmb = new _ContextMenuBuilder(e, deckTable, catTable, onRemove);
|
||||
childController.buildRemoveContextMenu(cmb);
|
||||
cmb.show();
|
||||
}
|
||||
public void onLeftDoubleClick(MouseEvent e) {
|
||||
removeSelectedCards(false, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(MouseEvent e) {
|
||||
_ContextMenuBuilder cmb = new _ContextMenuBuilder(e, deckTable, catTable, onRemove);
|
||||
childController.buildRemoveContextMenu(cmb);
|
||||
cmb.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -16,21 +16,21 @@ public abstract class FMouseAdapter extends MouseAdapter {
|
||||
public void onLeftMouseDown(MouseEvent e) {}
|
||||
public void onLeftMouseUp(MouseEvent e) {}
|
||||
public void onLeftClick(MouseEvent e) {}
|
||||
public void onLeftDblClick(MouseEvent e) {}
|
||||
public void onLeftDoubleClick(MouseEvent e) {}
|
||||
public void onLeftMouseDragging(MouseEvent e) {}
|
||||
public void onLeftMouseDragDrop(MouseEvent e) {}
|
||||
|
||||
public void onMiddleMouseDown(MouseEvent e) {}
|
||||
public void onMiddleMouseUp(MouseEvent e) {}
|
||||
public void onMiddleClick(MouseEvent e) {}
|
||||
public void onMiddleDblClick(MouseEvent e) {}
|
||||
public void onMiddleDoubleClick(MouseEvent e) {}
|
||||
public void onMiddleMouseDragging(MouseEvent e) {}
|
||||
public void onMiddleMouseDragDrop(MouseEvent e) {}
|
||||
|
||||
public void onRightMouseDown(MouseEvent e) {}
|
||||
public void onRightMouseUp(MouseEvent e) {}
|
||||
public void onRightClick(MouseEvent e) {}
|
||||
public void onRightDblClick(MouseEvent e) {}
|
||||
public void onRightDoubleClick(MouseEvent e) {}
|
||||
public void onRightMouseDragging(MouseEvent e) {}
|
||||
public void onRightMouseDragDrop(MouseEvent e) {}
|
||||
|
||||
@@ -90,17 +90,17 @@ public abstract class FMouseAdapter extends MouseAdapter {
|
||||
if (firstClickLoc != null) {
|
||||
//if first mouse down resulted in click and second mouse down with same button in close proximity,
|
||||
//handle double click event (don't wait until second mouse up to improve responsiveness)
|
||||
if (e.getClickCount() == 2 && e.getButton() == firstClickButton &&
|
||||
if (e.getClickCount() % 2 == 0 && e.getButton() == firstClickButton &&
|
||||
e.getLocationOnScreen().distance(firstClickLoc) <= 3) {
|
||||
switch (firstClickButton) {
|
||||
case 1:
|
||||
onLeftDblClick(e);
|
||||
onLeftDoubleClick(e);
|
||||
break;
|
||||
case 2:
|
||||
onMiddleDblClick(e);
|
||||
onMiddleDoubleClick(e);
|
||||
break;
|
||||
case 3:
|
||||
onRightDblClick(e);
|
||||
onRightDoubleClick(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public abstract class FMouseAdapter extends MouseAdapter {
|
||||
//if mouse down on component and not cleared by drag or exit, handle click
|
||||
if (mouseDownLoc != null) {
|
||||
//if first click, cache button and mouse down location for determination of double click later
|
||||
if (e.getClickCount() == 1) {
|
||||
if (e.getClickCount() % 2 == 1) {
|
||||
firstClickButton = e.getButton();
|
||||
firstClickLoc = mouseDownLoc;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeftDblClick(final MouseEvent e) {
|
||||
public void onLeftDoubleClick(final MouseEvent e) {
|
||||
DeckLister.this.editDeck(RowPanel.this.deck);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user