diff --git a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java index 0fbd3dbe9e..932a5bc3ee 100644 --- a/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java +++ b/Mage.Client/src/main/java/mage/client/chat/ChatPanelBasic.java @@ -351,6 +351,10 @@ public class ChatPanelBasic extends javax.swing.JPanel { this.txtMessage.repaint(); } } + + public void enableHyperlinks() { + txtConversation.enableHyperlinks(); + } private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped handleKeyTyped(evt); diff --git a/Mage.Client/src/main/java/mage/client/components/ColorPane.java b/Mage.Client/src/main/java/mage/client/components/ColorPane.java index deb15736e7..fa708fbe5d 100644 --- a/Mage.Client/src/main/java/mage/client/components/ColorPane.java +++ b/Mage.Client/src/main/java/mage/client/components/ColorPane.java @@ -39,10 +39,14 @@ public class ColorPane extends JEditorPane { HTMLDocument doc = new HTMLDocument(); private int tooltipDelay; private int tooltipCounter; + private boolean hyperlinkEnabled = false; public ColorPane() { this.setEditorKit(kit); this.setDocument(doc); + } + + private void addHyperlinkHandlers() { addHyperlinkListener(new HyperlinkListener() { @Override @@ -62,7 +66,7 @@ public class ColorPane extends JEditorPane { if (e.getEventType() == EventType.EXITED) { setPopupVisibility(container, false); } - if (e.getEventType() == EventType.ENTERED) { + if (e.getEventType() == EventType.ENTERED && card != null) { CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE); cardInfoPane.setCard(new CardView(card.getMockCard()), container); setPopupVisibility(container, true); @@ -76,7 +80,7 @@ public class ColorPane extends JEditorPane { } }); - + addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { @@ -89,21 +93,22 @@ public class ColorPane extends JEditorPane { } }); } - - private void setPopupVisibility(final Component container, final boolean show) - throws InterruptedException { + + private void setPopupVisibility(final Component container, final boolean show) throws InterruptedException { final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - Point location = new Point(getLocationOnScreen().x - container.getWidth(), MouseInfo.getPointerInfo().getLocation().y); - Component parentComponent = MageFrame.getInstance(); - location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), container, parentComponent); - container.setLocation(location); tooltipCounter += show ? 1 : -1; if (tooltipCounter < 0) { tooltipCounter = 0; } + if (tooltipCounter > 0) { + Point location = new Point(getLocationOnScreen().x - container.getWidth(), MouseInfo.getPointerInfo().getLocation().y); + Component parentComponent = MageFrame.getInstance(); + location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), container, parentComponent); + container.setLocation(location); + } container.setVisible(tooltipCounter > 0); c.repaint(); } @@ -131,7 +136,9 @@ public class ColorPane extends JEditorPane { public void append(String text) { try { - text = text.replaceAll("(]*>([^<]*)) (\\[[0-9a-fA-F]*\\])", "$1 $3"); + if (hyperlinkEnabled) { + text = text.replaceAll("(]*>([^<]*)) (\\[[0-9a-fA-F]*\\])", "$1 $3"); + } setEditable(true); kit.insertHTML(doc, doc.getLength(), text, 0, 0, null); setEditable(false); @@ -163,4 +170,9 @@ public class ColorPane extends JEditorPane { super.paintChildren(g); } + public void enableHyperlinks(){ + hyperlinkEnabled = true; + addHyperlinkHandlers(); + } + } diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java index a340a21153..3fd791d392 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java @@ -1296,6 +1296,7 @@ public final class GamePanel extends javax.swing.JPanel { gameChatPanel.setConnectedChat(userChatPanel); gameChatPanel.disableInput(); gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48)); + gameChatPanel.enableHyperlinks(); jSplitPane2 = new javax.swing.JSplitPane(); handContainer = new HandPanel(); handCards = new HashMap<>();