added deactivating text (and selectbox) gadgets with "Escape" key
authorHolger Schemel <info@artsoft.org>
Fri, 16 Nov 2018 20:52:26 +0000 (21:52 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 16 Nov 2018 20:53:05 +0000 (21:53 +0100)
src/libgame/gadgets.c

index 4b237b8..0295eec 100644 (file)
@@ -2117,7 +2117,18 @@ boolean HandleGadgetsKeyInput(Key key)
 
   if (key == KSYM_Escape)
   {
-    StopTextInput();
+    if (anyTextGadgetActive())
+    {
+      // restore previous text (before activating text gadget)
+      if (gi->type & GD_TYPE_TEXT_INPUT)
+       strcpy(gi->textinput.value, gi->textinput.last_value);
+
+      DrawGadget(gi, DG_UNPRESSED, gi->direct_draw);
+
+      last_gi = NULL;
+
+      StopTextInput();
+    }
   }
   else if (key == KSYM_Return) // valid for both text input and selectbox
   {