From daa0897ec9709b67da8a42ec5434c936d2f83506 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 31 Mar 2013 19:32:49 +0000 Subject: 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; } -- cgit v1.2.3