The bug
Entering the screen to add or edit a server on the multiplayer server list, two input boxes and several buttons appear. When clicking somewhere outside the input boxes and none of the buttons, the blinking cursor disappears. Then I pressed the TAB
key and the cursor started blinking on both the name box and the address box at the same time and I could write in both boxes at the same time.
How to reproduce
Click the "Multiplayer" button in the main menu
Click "Add server" or select one previously added server and click "Edit server"
Click somewhere on the dirt background
Press the
TAB
keyStart writing
Note: This bug did not happen before any 1.6 release
Code analysis
Code analysis by @unknown can be found in this comment.
Linked issues
is duplicated by 2
Attachments
Comments 4
The following is based on MCP 9.40pre-1 using MC 1.12. (Can confirm for 1.12.1)
This is because there is no check in the net.minecraft.client.gui.GuiScreenAddServer.keyTyped()
method if there is at least one focused text box. The game just assumes that there is one and invokes the setFocused(!isFocusedIn)
method for both text boxes. As they both have no focus when the tab button is pressed in this case, isFocusedIn
is false for both and they are set focused. This issue can be fixed by simply adding the missing check to the method. -> if(!this.serverNameField.isFocused() && !this.serverIPField.isFocused())
Suggested fix
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
this.serverNameField.textboxKeyTyped(typedChar, keyCode);
this.serverIPField.textboxKeyTyped(typedChar, keyCode);
if (keyCode == 15)
{
if(!this.serverNameField.isFocused() && !this.serverIPField.isFocused())
{
this.serverNameField.setFocused(!this.serverNameField.isFocused());
}
else
{
this.serverNameField.setFocused(!this.serverNameField.isFocused());
this.serverIPField.setFocused(!this.serverIPField.isFocused());
}
}
if (keyCode == 28 || keyCode == 156)
{
this.actionPerformed(this.buttonList.get(0));
}
(this.buttonList.get(0)).enabled = !this.serverIPField.getText().isEmpty() && this.serverIPField.getText().split(":").length > 0 && !this.serverNameField.getText().isEmpty();
}
Confirmed.