shithub: choc

Download patch

ref: daa0897ec9709b67da8a42ec5434c936d2f83506
parent: 9963de836f199c57b327b482b838d1e0b1e2bf91
author: Simon Howard <fraggle@gmail.com>
date: Sun Mar 31 15:32:49 EDT 2013

Allow backspace or delete to clear the contents of an input box.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2574

--- a/textscreen/txt_inputbox.c
+++ b/textscreen/txt_inputbox.c
@@ -216,6 +216,15 @@
             return 1;
         }
 
+        // Backspace or delete erases the contents of the box.
+
+        if ((key == KEY_DEL || key == KEY_BACKSPACE)
+         && inputbox->widget.widget_class == &txt_inputbox_class)
+        {
+            free(*((char **)inputbox->value));
+            *((char **) inputbox->value) = strdup("");
+        }
+
         return 0;
     }