- add ctrl(cmd)+enter hotkey to auto button in ability chooser dialog

- scroll game log to top on display
This commit is contained in:
myk
2013-02-07 00:30:56 +00:00
parent 480124f407
commit f552ffbed6
2 changed files with 20 additions and 3 deletions

View File

@@ -19,6 +19,8 @@ import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import com.google.common.base.Function;
import forge.Card;
import forge.card.spellability.SpellAbility;
import forge.gui.match.CMatchUI;
@@ -306,12 +308,27 @@ public class DualListBox<T> extends FPanel {
onRemove.run();
}
};
final Function<KeyEvent, Void> onEnter = new Function<KeyEvent, Void>() {
@Override
public Void apply (KeyEvent e) {
if (e.getKeyCode() == 10) {
if (e.isControlDown() || e.isMetaDown()) {
autoButton.doClick();
} else {
okButton.doClick();
}
}
return null;
}
};
sourceList.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
if (e.getKeyChar() == ' ') { onAdd.run(); }
else if (e.getKeyCode() == 10) { okButton.doClick(); }
else { onEnter.apply(e); }
}
});
@@ -319,7 +336,7 @@ public class DualListBox<T> extends FPanel {
@Override
public void keyPressed(final KeyEvent e) {
if (e.getKeyChar() == ' ') { onRemove.run(); }
else if (e.getKeyCode() == 10) { okButton.doClick(); }
else { onEnter.apply(e); }
}
});

View File

@@ -151,7 +151,6 @@ public class ViewWinLose {
final JPanel pnlLog = new JPanel(new MigLayout("insets 0, wrap, ax center"));
final FScrollPane scrLog = new FScrollPane(txtLog);
scrLog.getViewport().setViewPosition(new Point(0, 0));
scrLog.setBorder(null);
pnlLog.setOpaque(false);
@@ -168,6 +167,7 @@ public class ViewWinLose {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
scrLog.getViewport().setViewPosition(new Point(0, 0));
focusButton.requestFocusInWindow();
}
});