Possible fix for Issue 256

This commit is contained in:
magenoxx 2011-09-21 12:25:22 +04:00
parent 015ea665af
commit a4fd5e6fb7
3 changed files with 29 additions and 1 deletions

View file

@ -44,6 +44,7 @@ import java.util.UUID;
import javax.swing.*;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import mage.client.components.MageTextArea;
import mage.client.dialog.MageDialog;
import mage.remote.Session;
@ -67,6 +68,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
private Session session;
private FeedbackMode mode;
private MageDialog connectedDialog;
private ChatPanel connectedChatPanel;
/** Creates new form FeedbackPanel */
public FeedbackPanel() {
@ -125,14 +127,16 @@ public class FeedbackPanel extends javax.swing.JPanel {
}
this.btnSpecial.setVisible(special);
this.btnSpecial.setText("Special");
this.btnRight.requestFocus();
this.helper.setSpecial("Special", special);
if (message.contains("P}")) {
this.btnSpecial.setVisible(true);
this.btnSpecial.setText("Pay 2 life");
this.helper.setSpecial("Pay 2 life", true);
}
requestFocusIfPossible();
handleOptions(options);
this.revalidate();
this.repaint();
this.helper.setLinks(btnLeft, btnRight, btnSpecial);
@ -156,6 +160,19 @@ public class FeedbackPanel extends javax.swing.JPanel {
}
}
// Issue 256: Chat+Feedback panel: request focus prevents players from chatting
private void requestFocusIfPossible() {
boolean requestFocusAllowed = true;
if (connectedChatPanel != null && connectedChatPanel.getTxtMessageInputComponent() != null) {
if (connectedChatPanel.getTxtMessageInputComponent().hasFocus()) {
requestFocusAllowed = false;
}
}
if (requestFocusAllowed) {
this.btnRight.requestFocus();
}
}
public void doClick() {
this.btnRight.doClick();
}
@ -382,6 +399,10 @@ public class FeedbackPanel extends javax.swing.JPanel {
return this.mode;
}
public void setConnectedChatPanel(ChatPanel chatPanel) {
this.connectedChatPanel = chatPanel;
}
private javax.swing.JButton btnLeft;
private javax.swing.JButton btnRight;
private javax.swing.JButton btnSpecial;