From 5433e9bd19b9c3a42f8db569bf8f47d6dbe4f0c5 Mon Sep 17 00:00:00 2001
From: Auke Kok <sofar@foo-projects.org>
Date: Fri, 14 Apr 2017 22:16:57 -0700
Subject: [PATCH] Don't make TAB exit game if bound to inventory.

I play with the TAB key bound to the inventory. However, the
code here assumes that TAB means "close formspec" in all contexts,
including the main menu. This causes my game to exit when I attempt
to TAB in between USERNAME and PASSWORD fields.

We know when m_client != NULL that the game is a client game and
not in the main menu, and then it's OK to use the INVENTORY bound
key to exit the formspec, since it's not the main menu.
---
 src/guiFormSpecMenu.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp
index 330124fe1..3fe3c5cc2 100644
--- a/src/guiFormSpecMenu.cpp
+++ b/src/guiFormSpecMenu.cpp
@@ -3296,8 +3296,9 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
 {
 	if (event.EventType==EET_KEY_INPUT_EVENT) {
 		KeyPress kp(event.KeyInput);
-		if (event.KeyInput.PressedDown && ( (kp == EscapeKey) ||
-				(kp == getKeySetting("keymap_inventory")) || (kp == CancelKey))) {
+		if (event.KeyInput.PressedDown && (
+				(kp == EscapeKey) || (kp == CancelKey) ||
+				((m_client != NULL) && (kp == getKeySetting("keymap_inventory"))))) {
 			tryClose();
 			return true;
 		} else if (m_client != NULL && event.KeyInput.PressedDown &&