When you're in the commandblock UI you can't go back to the game when pressing the escape button. The escape button works in basically all UI's so you'd expect it to happen for the commandblock UI too.
(also the [enter] button would by handy, but that's another issue)
Comments 8
Fixes
GuiCommandBlock
protected void keyTyped(char par1, int par2) {
// ADDED:
if (par2 == 1)
this.actionPerformed((GuiButton) this.controlList.get(1));
...
GuiEditSign
protected void keyTyped(char par1, int par2) {
// ADDED:
if (par2 == 1) {
this.entitySign.onInventoryChanged();
this.mc.displayGuiScreen((GuiScreen) null);
return;
}
...
Tested on 1.4.7. (Oh yeah, affects 1.4.7). ESC on command block makes "cancel", but I made it to save the text on sign (more convenient for that).
I think escape as Cancel is better, isn't that how it is for everything else?
Escape never confirmed changes that aren't already saved.
The thing is, sign-editing GUI has no "cancel" 😛 It only has action "Done".
Also, the sign text is edited "directly", whatever is typed goes immediately into the sign entity. There is no "undo buffer" that could be used for cancel. And the GUI sends changes to server whenever the GUI is closed, no matter how it is closed. There's lots to change in order to support cancel.
Oh well...
Edit: realized that the reason for not having cancel is that the sign will always be created once the placement/editing has started, and that existing signs can not be edited. Thus, if one cancels, the sign is just left empty, which is most of times not useful... well, I guess all the people abusing signs for other than showing text would disagree.
Anyway, necessary changes to support canceling the text (i.e. quick placing an empty sign):
GuiEditSign
...
// ADDED
public String[] oldText = new String[] {"", "", "", ""};
private boolean cancel = false;
...
public void initGui() {
...
// ADDED
oldText = new String[4];
System.arraycopy(this.entitySign.signText, 0, oldText, 0, 4);
this.cancel = false;
}
public void onGuiClosed() {
// ADDED the wrapping in the 'if' and the last row (though that last row is likely unnecessary.
if (!cancel) {
Keyboard.enableRepeatEvents(false);
NetClientHandler var1 = this.mc.getSendQueue();
if (var1 != null) {
var1.addToSendQueue(new Packet130UpdateSign(this.entitySign.xCoord, this.entitySign.yCoord, this.entitySign.zCoord, this.entitySign.signText));
}
this.entitySign.setEditable(true);
}
this.cancel = false;
}
protected void keyTyped(char par1, int par2) {
// ESC FIX
if (par2 == 1) {
this.cancel = true;
// Restore old values:
System.arraycopy(oldText, 0, this.entitySign.signText, 0, 4);
this.mc.displayGuiScreen((GuiScreen) null);
return;
}
...
}
The storing of the "old text" is currently unnecessary, as all signs can only be empty when they get there. However, anticipating a convenience change in future to allow editing existing signs, the copy of the old text would handle it already.
Didn't know that signs didn't have a buffer.
I knew changes in the settings and other GUI-based stuff can't cancel on close, but that's because those changes are saved when they happen.
Confirmed.
Applies also to signs.