commit daa0897ec9709b67da8a42ec5434c936d2f83506
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Mar 31 19:32:49 2013 +0000
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Sun Mar 31 19:32:49 2013 +0000
Allow backspace or delete to clear the contents of an input box.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2574
---
textscreen/txt_inputbox.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/textscreen/txt_inputbox.c b/textscreen/txt_inputbox.c
index da872c9c..13d35aef 100644
--- a/textscreen/txt_inputbox.c
+++ b/textscreen/txt_inputbox.c
@@ -216,6 +216,15 @@ static int TXT_InputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key)
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;
}