How to replicate the bug
Step 1: Open Minecraft and find a button that does not change screens (like the change difficulty button or the resolution changer button) or find a slider (like the max fps slider in the Video Settings)
Step 2: Click the button or drag the slider with the mouse
Expected result:
Button/slider loses focus after unhovering it
Actual result
Button/slider stays focused
The exact issue is in ContainerEventHandler.mouseClicked(final MouseButtonEvent event, final boolean doubleClick), where the code
if (widget.mouseClicked(event, doubleClick) && widget.shouldTakeFocusAfterInteraction()) {
this.setFocused(widget);
if (event.button() == 0) {
this.setDragging(true);
}
}sets the widget focused if it is clicked, while AbstractButton.extractDefaultSprite(final GuiGraphicsExtractor graphics) blits the sprite as the following
SPRITES.get(this.active, this.overrideRenderHighlightedSprite != null ? (Boolean)this.overrideRenderHighlightedSprite.get() : this.isHoveredOrFocused())with SPRITES defined as
private static final WidgetSprites SPRITES = new WidgetSprites(
Identifier.withDefaultNamespace("widget/button"),
Identifier.withDefaultNamespace("widget/button_disabled"),
Identifier.withDefaultNamespace("widget/button_highlighted")
);But since this.overrideRenderHighlightedSprite == null for almost all buttons, the sprite will be given by SPRITES.get(this.active, this.isHoveredorFocused())
However, this should be isHovered() if the button was clicked by the mouse or isFocused() if it was clicked by navigating through the keyboard
The fix to this is to either not set the widget as focused in ContainerEventHandler.mouseClicked() or differentiate between mouse clicks and keyboard clicks, or check if the mouse is over the button when AbstractButton.extractDefaultSprite() is called with this.isMouseOver(mouseX, mouseY) (if true, donβt set the button focused, if false, handle like normal)
Thank you for your report!
We're tracking this issue in MC-259387, so this ticket is being resolved and linked as a Duplicate.
If you would like to add a vote and any extra information to the main ticket, it would be appreciated.
If you haven't already, please make use of the search feature to see if an issue you are about to report has already been reported.
Quick Links:
π Bug Tracker Guidelines β π¬ Community Support β π§ Mojang Support (Technical Issues) β π§ Microsoft Support (Account Issues)
π Project Summary β βοΈ Feedback and Suggestions β π Game Wiki