mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fix so I-Beam cursor displayed when over text fields
This commit is contained in:
@@ -3,6 +3,8 @@ package forge.gui;
|
||||
import forge.view.FView;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public final class MouseUtil {
|
||||
private MouseUtil() { }
|
||||
@@ -57,4 +59,18 @@ public final class MouseUtil {
|
||||
if (cursorLockCount > 0) { return; }
|
||||
FView.SINGLETON_INSTANCE.getLpnDocument().setCursor(cursor);
|
||||
}
|
||||
|
||||
public static void setComponentCursor(final Component comp, final Cursor cursor0) {
|
||||
comp.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
setCursor(cursor0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.gui.toolbox;
|
||||
|
||||
import forge.gui.MouseUtil;
|
||||
import forge.gui.toolbox.FSkin.SkinnedTextField;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -8,6 +9,7 @@ import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.PlainDocument;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
@@ -70,6 +72,9 @@ public class FTextField extends SkinnedTextField {
|
||||
this.setText(builder.text);
|
||||
this.setToolTipText(builder.toolTip);
|
||||
this.setFocusable(true);
|
||||
if (this.isEditable()) {
|
||||
MouseUtil.setComponentCursor(this, Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
}
|
||||
|
||||
addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user