GUI: improved stability of popup hint window (fixed game freeze in some use cases, fixes #11595)

This commit is contained in:
Oleg Agafonov 2024-01-15 19:57:33 +04:00
parent 35334f50b6
commit 7bda2d95d2

View file

@ -59,7 +59,7 @@ public class MageEditorPane extends JEditorPane {
} }
public void cleanUp() { public void cleanUp() {
resetCursor(); setCursorToDefault();
} }
private void addHyperlinkHandlers() { private void addHyperlinkHandlers() {
@ -171,17 +171,23 @@ public class MageEditorPane extends JEditorPane {
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
cardInfo.onMouseExited(); cardInfo.onMouseExited();
resetCursor(); setCursorToDefault();
} }
}); });
} }
private void resetCursor() { private void setCursorToDefault() {
SwingUtilities.windowForComponent(this).setCursor(Cursor.getDefaultCursor()); Window parent = SwingUtilities.windowForComponent(this);
if (parent != null) {
parent.setCursor(Cursor.getDefaultCursor());
}
} }
private void setCursorToHand() { private void setCursorToHand() {
SwingUtilities.windowForComponent(this).setCursor(new Cursor(Cursor.HAND_CURSOR)); Window parent = SwingUtilities.windowForComponent(this);
if (parent != null) {
parent.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
} }
private void urlHighlightEnable(Element hyperlinkElement) { private void urlHighlightEnable(Element hyperlinkElement) {
@ -197,7 +203,7 @@ public class MageEditorPane extends JEditorPane {
changeUrlTextDecoration(lastUrlElementEntered, "none"); changeUrlTextDecoration(lastUrlElementEntered, "none");
lastUrlElementEntered = null; lastUrlElementEntered = null;
} }
resetCursor(); setCursorToDefault();
} }
private void changeUrlTextDecoration(Element el, String decoration) { private void changeUrlTextDecoration(Element el, String decoration) {