[MC-10874] the [esc] key doesn't work when you're in the command block menu and when placing signs Created: 03/Mar/13  Updated: 29/Dec/17  Resolved: 16/Mar/13

Status: Resolved
Project: Minecraft: Java Edition
Component/s: None
Affects Version/s: Snapshot 13w09c
Fix Version/s: Minecraft 1.5

Type: Bug
Reporter: Jesper the End Assignee: Unassigned
Resolution: Fixed Votes: 2
Labels: UI, command, command_block
Environment:

Mac OS X, but I don't think that matters


CHK:
Confirmation Status: Confirmed

 Description   

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   
Comment by Markku [ 16/Mar/13 ]

Just for reference, looks like these were fixed the way shown in the first part; for command block esc equals cancel, for signs it equals save/done.

Comment by Kumasasa [ 16/Mar/13 ]

Ninja fix. Also fixed for signs.

Comment by Jesper the End [ 16/Mar/13 ]

fixed for 1.5 (didn't even notice)

Comment by George Gates [ 05/Mar/13 ]

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.

Comment by Markku [ 04/Mar/13 ]

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.

Comment by George Gates [ 04/Mar/13 ]

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.

Comment by Markku [ 03/Mar/13 ]

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).

Comment by Kumasasa [ 03/Mar/13 ]

Confirmed.
Applies also to signs.

Generated at Sun Jan 12 12:25:48 UTC 2025 using Jira 9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13.