Text fields persistently highlight when you press shift
The bug
I've noticed this issue for a few years and, up until now, I never knew what the issue was. I would press shift to capitalise a character then go to click and the text starts to be highlighted. I found that you have to press either control, alt, or arrow keys to stop highlighting the text field but this isn't ideal as most players wouldn't know this.
To reproduce
- Type anything in a text field then press shift and let go
- Move your caret by clicking
- Text should be highlighted
- Press either the ctrl, alt, or arrow keys to deselect
I expected to only select text when I hold shift, not when I press it once.
Code analysis
Code analysis by Malo can be found in this comment.
Linked Issues
Created Issue:
Text fields persistently highlight when you press shift
I've noticed this issue for a few years and, up until now, I never knew what the issue was. I would press shift to capitalise a character then go to click and the text starts to be highlighted. I found that you have to press either control, alt, or arrow keys to stop highlighting the text field but this isn't ideal as most players wouldn't know this.
How to replicate:
Type anything in a text field then press shift and let go
Move your caret by clicking
Text should be highlighted
Press either the ctrl, alt, or arrow keys to deselect
I expected to only select text when I hold shift, not when I press it once.
relates to
I've noticed this issue for a few years and, up until now, I never knew what the issue was. I would press shift to capitalise a character then go to click and the text starts to be highlighted. I found that you have to press either control, alt, or arrow keys to stop highlighting the text field but this isn't ideal as most players wouldn't know this.
How to replicate:
Type anything in a text field then press shift and let go
Move your caret by clicking
Text should be highlighted
Press either the ctrl, alt, or arrow keys to deselect
I expected to only select text when I hold shift, not when I press it once.
I've noticed this issue for a few years and, up until now, I never knew what the issue was. I would press shift to capitalise a character then go to click and the text starts to be highlighted. I found that you have to press either control, alt, or arrow keys to stop highlighting the text field but this isn't ideal as most players wouldn't know this.
How to replicate:
- Type anything in a text field then press shift and let go
- Move your caret by clicking
- Text should be highlighted
- Press either the ctrl, alt, or arrow keys to deselect
I expected to only select text when I hold shift, not when I press it once.
is duplicated by
I've noticed this issue for a few years and, up until now, I never knew what the issue was. I would press shift to capitalise a character then go to click and the text starts to be highlighted. I found that you have to press either control, alt, or arrow keys to stop highlighting the text field but this isn't ideal as most players wouldn't know this.
How to replicate:
- Type anything in a text field then press shift and let go
- Move your caret by clicking
- Text should be highlighted
- Press either the ctrl, alt, or arrow keys to deselect
I expected to only select text when I hold shift, not when I press it once.
The bug
I've noticed this issue for a few years and, up until now, I never knew what the issue was. I would press shift to capitalise a character then go to click and the text starts to be highlighted. I found that you have to press either control, alt, or arrow keys to stop highlighting the text field but this isn't ideal as most players wouldn't know this.
To reproduce
- Type anything in a text field then press shift and let go
- Move your caret by clicking
- Text should be highlighted
- Press either the ctrl, alt, or arrow keys to deselect
I expected to only select text when I hold shift, not when I press it once.
Code analysis
Code analysis by Malo can be found in this comment.
duplicates
is duplicated by
relates to
Thank you for your report!
We're tracking this issue in MC-260563, 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, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
Hard to show on video, but the steps to reproduce explain it pretty well. Effectively, the shift key still affects the cursor after being released. In the video I just attached, the shift key is never held when I'm clicking into the text field.
This issue is due to net.minecraft.client.gui.components.EditBox#moveCursorTo testing if the Shift key is down by reading the shiftPressed field, which is not updated properly before moveCursor is called in mouseClicked.
This shiftPressed field is useless because it is private and only used by moveCursorTo and keyPressed, which updates it with a call to net.minecraft.client.gui.screens.Screen#hasShiftDown. keyPressed sets shiftPressed to false before calling deleteText at two places, but this is useless because shiftPressed is only ever read by moveCursor.
Fixing this issue should be as easy as completely removing the shiftPressed field in EditBox, and replacing it in moveCursorTo with a call to Screen#hasShiftDown.
Affects 1.20.1