31
31
* <p>
32
32
* The rendering does pay attention to the size of the '_' caret.
33
33
*/
34
- public class MEGuiTextField extends GuiTextField
35
- {
34
+ public class MEGuiTextField extends GuiTextField implements ITooltip {
36
35
private static final int PADDING = 2 ;
36
+ private String tooltip ;
37
37
38
38
private final int _xPos ;
39
39
private final int _yPos ;
@@ -50,9 +50,8 @@ public class MEGuiTextField extends GuiTextField
50
50
* @param width absolute width
51
51
* @param height absolute height
52
52
*/
53
- public MEGuiTextField ( final FontRenderer fontRenderer , final int xPos , final int yPos , final int width , final int height )
54
- {
55
- super ( fontRenderer , xPos + PADDING , yPos + PADDING , width - 2 * PADDING - fontRenderer .getCharWidth ( '_' ), height - 2 * PADDING );
53
+ public MEGuiTextField (final FontRenderer fontRenderer , final int xPos , final int yPos , final int width , final int height ) {
54
+ super (fontRenderer , xPos + PADDING , yPos + PADDING , width - 2 * PADDING - fontRenderer .getCharWidth ('_' ), height - 2 * PADDING );
56
55
57
56
this ._xPos = xPos ;
58
57
this ._yPos = yPos ;
@@ -61,13 +60,12 @@ public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final in
61
60
}
62
61
63
62
@ Override
64
- public void mouseClicked ( final int xPos , final int yPos , final int button )
65
- {
66
- super .mouseClicked ( xPos , yPos , button );
63
+ public void mouseClicked (final int xPos , final int yPos , final int button ) {
64
+ super .mouseClicked (xPos , yPos , button );
67
65
68
- final boolean requiresFocus = this .isMouseIn ( xPos , yPos );
66
+ final boolean requiresFocus = this .isMouseIn (xPos , yPos );
69
67
70
- this .setFocused ( requiresFocus );
68
+ this .setFocused (requiresFocus );
71
69
}
72
70
73
71
/**
@@ -77,11 +75,40 @@ public void mouseClicked( final int xPos, final int yPos, final int button )
77
75
* @param yCoord current y coord of the mouse
78
76
* @return true if mouse position is within the text field area
79
77
*/
80
- public boolean isMouseIn ( final int xCoord , final int yCoord )
81
- {
78
+ public boolean isMouseIn (final int xCoord , final int yCoord ) {
82
79
final boolean withinXRange = this ._xPos <= xCoord && xCoord < this ._xPos + this ._width ;
83
80
final boolean withinYRange = this ._yPos <= yCoord && yCoord < this ._yPos + this ._height ;
84
81
85
82
return withinXRange && withinYRange ;
86
83
}
84
+
85
+ @ Override
86
+ public String getMessage () {
87
+ return tooltip ;
88
+ }
89
+
90
+ public void setMessage (String tooltip )
91
+ {
92
+ this .tooltip = tooltip ;
93
+ }
94
+
95
+ @ Override
96
+ public int xPos () {
97
+ return this ._xPos ;
98
+ }
99
+
100
+ @ Override
101
+ public int yPos () {
102
+ return this ._yPos ;
103
+ }
104
+
105
+ @ Override
106
+ public int getHeight () {
107
+ return 22 ;
108
+ }
109
+
110
+ @ Override
111
+ public boolean isVisible () {
112
+ return getVisible ();
113
+ }
87
114
}
0 commit comments