Fix QuartzKnife GUI input text-field interaction.
This commit is contained in:
@@ -18,16 +18,18 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
@@ -68,7 +70,7 @@ public class GuiQuartzKnife extends AEBaseGui<ContainerQuartzKnife> {
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (this.name.charTyped(character, key)) {
|
||||
if (this.name.isFocused() && this.name.charTyped(character, key)) {
|
||||
final String Out = this.name.getText();
|
||||
container.setName(Out);
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out));
|
||||
@@ -80,11 +82,33 @@ public class GuiQuartzKnife extends AEBaseGui<ContainerQuartzKnife> {
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (this.name.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
final String Out = this.name.getText();
|
||||
container.setName(Out);
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out));
|
||||
return true;
|
||||
|
||||
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
|
||||
|
||||
if (keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(input)) {
|
||||
if (AppEng.proxy.isActionKey(ActionKey.TOGGLE_FOCUS, input)) {
|
||||
this.name.setFocused2(!this.name.isFocused());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.name.isFocused()) {
|
||||
if (keyCode == GLFW.GLFW_KEY_ENTER) {
|
||||
this.name.setFocused2(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.name.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
final String Out = this.name.getText();
|
||||
container.setName(Out);
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out));
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to swallow key presses if the field is focused because typing 'e'
|
||||
// would otherwise close
|
||||
// the screen
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
|
||||
Reference in New Issue
Block a user