@@ -35,6 +35,7 @@ public class GuiButton extends GuiElement<GuiButton> {
35
35
private Supplier <Boolean > disabled = () -> false ;
36
36
private Supplier <Boolean > toggleState ;
37
37
private GuiText label = null ;
38
+ private boolean resetHoverOnPress = true ;
38
39
39
40
/**
40
41
* In its default state this is a blank, invisible element that can fire callbacks when pressed.
@@ -164,6 +165,15 @@ public GuiText getLabel() {
164
165
return label ;
165
166
}
166
167
168
+ /**
169
+ * By default, hover time is reset when button is pressed.
170
+ * THis allows you to disable that functionality to the tooltip will remain open when button is pressed.
171
+ */
172
+ public GuiButton setResetHoverOnPress (boolean resetHoverOnPress ) {
173
+ this .resetHoverOnPress = resetHoverOnPress ;
174
+ return this ;
175
+ }
176
+
167
177
/**
168
178
* This event is fired immediately when this button is left-clicked.
169
179
* This is the logic used by most vanilla gui buttons.
@@ -294,7 +304,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
294
304
Runnable onPress = this .onPress .get (button );
295
305
if (onClick == null && onPress == null ) return false ;
296
306
pressed = true ;
297
- hoverTime = 1 ;
307
+ if ( resetHoverOnPress ) hoverTime = 1 ;
298
308
299
309
boolean consume = false ;
300
310
if (onClick != null ) {
@@ -318,7 +328,7 @@ public boolean mouseReleased(double mouseX, double mouseY, int button, boolean c
318
328
Runnable onClick = this .onClick .get (button );
319
329
Runnable onPress = this .onPress .get (button );
320
330
if (onClick == null && onPress == null ) return consumed ;
321
- hoverTime = 1 ;
331
+ if ( resetHoverOnPress ) hoverTime = 1 ;
322
332
323
333
if (!isDisabled () && isMouseOver ()) {
324
334
if (pressed && onPress != null ) {
0 commit comments