mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 21:15:53 +08:00
Fix: Escape key consumed by KeybindComponent prevents GUI close; keyTyped returns boolean
This commit is contained in:
1 parent
5713cc9fb8
commit
1f40b701a8
6 files changed
+29
-29
No files matched your search
@@ -143,21 +143,19 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
char typedChar,
|
||||
int keyCode
|
||||
) throws java.io.IOException {
|
||||
boolean consumed = false;
|
||||
for (Panel panel : panels) {
|
||||
panel.keyTyped(
|
||||
typedChar,
|
||||
keyCode
|
||||
);
|
||||
if (panel.keyTyped(typedChar, keyCode))
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
if (keyCode == 1) {
|
||||
if (keyCode == 1 && !consumed) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
super.keyTyped(
|
||||
typedChar,
|
||||
keyCode
|
||||
);
|
||||
if (!consumed) {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -147,10 +147,13 @@ public class Panel {
|
||||
}
|
||||
|
||||
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
public boolean keyTyped(char typedChar, int keyCode) {
|
||||
boolean consumed = false;
|
||||
for (Component component : components) {
|
||||
component.keyTyped(typedChar, keyCode);
|
||||
if (component.keyTyped(typedChar, keyCode))
|
||||
consumed = true;
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,11 +58,11 @@ public abstract class Component {
|
||||
}
|
||||
|
||||
|
||||
public void keyTyped(
|
||||
public boolean keyTyped(
|
||||
char typedChar,
|
||||
int keyCode
|
||||
) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -105,12 +105,14 @@ public class ModuleButton extends Component {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
public boolean keyTyped(char typedChar, int keyCode) {
|
||||
if (expanded) {
|
||||
for (OptionComponent option : options) {
|
||||
option.keyTyped(typedChar, keyCode);
|
||||
if (option.keyTyped(typedChar, keyCode))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-9
@@ -46,22 +46,18 @@ public class KeybindComponent extends OptionComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
if (!listening) return;
|
||||
public boolean keyTyped(char typedChar, int keyCode) {
|
||||
if (!listening) return false;
|
||||
|
||||
if (keyCode == 1) {
|
||||
module.setKey(0);
|
||||
listening = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (keyCode == Keyboard.KEY_DELETE) {
|
||||
module.setKey(Keyboard.KEY_NONE);
|
||||
listening = false;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
module.setKey(keyCode);
|
||||
listening = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-5
@@ -94,13 +94,13 @@ public class StringComponent extends OptionComponent {
|
||||
|
||||
|
||||
@Override
|
||||
public void keyTyped(
|
||||
public boolean keyTyped(
|
||||
char typedChar,
|
||||
int keyCode
|
||||
) {
|
||||
|
||||
if(!typing)
|
||||
return;
|
||||
return false;
|
||||
|
||||
|
||||
// Backspace
|
||||
@@ -116,24 +116,25 @@ public class StringComponent extends OptionComponent {
|
||||
)
|
||||
);
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Enter
|
||||
if(keyCode == 28) {
|
||||
typing = false;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(Character.isISOControl(typedChar))
|
||||
return;
|
||||
return true;
|
||||
|
||||
|
||||
option.setValue(
|
||||
option.getValue() + typedChar
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user