Fix pasting text

This commit is contained in:
PeytonPlayz595 2024-07-31 02:38:33 -04:00
parent 66f995488e
commit c860c0e579
3 changed files with 24 additions and 4 deletions

View File

@ -21,7 +21,7 @@ public class GuiChat extends GuiScreen {
protected void keyTyped(char var1, int var2) { protected void keyTyped(char var1, int var2) {
if(var2 == 1) { if(var2 == 1) {
this.mc.displayGuiScreen((GuiScreen)null); this.mc.displayGuiScreen(null);
} else if(var2 == 28) { } else if(var2 == 28) {
String var3 = this.message.trim(); String var3 = this.message.trim();
if(var3.length() > 0) { if(var3.length() > 0) {
@ -32,6 +32,16 @@ public class GuiChat extends GuiScreen {
} }
this.mc.displayGuiScreen((GuiScreen)null); this.mc.displayGuiScreen((GuiScreen)null);
} else if((int)var1 == 16 || (GuiScreen.isCtrlKeyDown() && var2 == 47)) {
String string = GuiScreen.getClipboardString();
if (string == null) {
string = "";
}
this.message = this.message + string;
if(this.message.length() > 100) {
this.message = this.message.substring(0, 100);
}
return;
} else { } else {
if(var2 == 14 && this.message.length() > 0) { if(var2 == 14 && this.message.length() > 0) {
this.message = this.message.substring(0, this.message.length() - 1); this.message = this.message.substring(0, this.message.length() - 1);
@ -40,7 +50,6 @@ public class GuiChat extends GuiScreen {
if(field_20082_i.indexOf(var1) >= 0 && this.message.length() < 100) { if(field_20082_i.indexOf(var1) >= 0 && this.message.length() < 100) {
this.message = this.message + var1; this.message = this.message + var1;
} }
} }
} }

View File

@ -34,7 +34,12 @@ public class GuiScreen extends Gui {
} }
public static String getClipboardString() { public static String getClipboardString() {
return null; try {
String s = GL11.EaglerAdapterImpl2.getClipboard();
return s == null ? "" : s;
}catch(Throwable t) {
return "";
}
} }
protected void mouseClicked(int var1, int var2, int var3) { protected void mouseClicked(int var1, int var2, int var3) {
@ -152,4 +157,8 @@ public class GuiScreen extends Gui {
public void selectNextField() { public void selectNextField() {
} }
public static boolean isCtrlKeyDown() {
return Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157);
}
} }

View File

@ -41,7 +41,7 @@ public class GuiTextField extends Gui {
this.parentGuiScreen.selectNextField(); this.parentGuiScreen.selectNextField();
} }
if(var1 == 22) { if((int)var1 == 16 || (GuiScreen.isCtrlKeyDown() && var2 == 47)) {
String var3 = GuiScreen.getClipboardString(); String var3 = GuiScreen.getClipboardString();
if(var3 == null) { if(var3 == null) {
var3 = ""; var3 = "";
@ -55,6 +55,8 @@ public class GuiTextField extends Gui {
if(var4 > 0) { if(var4 > 0) {
this.text = this.text + var3.substring(0, var4); this.text = this.text + var3.substring(0, var4);
} }
return;
} }
if(var2 == 14 && this.text.length() > 0) { if(var2 == 14 && this.text.length() > 0) {