From 0dbc6e5ecdc3a4ec97fd65876051577e53fc1873 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 7 Nov 2019 21:20:04 +0000 Subject: fix keypress entry on text area accidentaly broken in commit fca421e2047a55f3cf575c92943c1116ec58da3c --- content/handlers/html/box_textarea.c | 51 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/content/handlers/html/box_textarea.c b/content/handlers/html/box_textarea.c index 8b4fdf954..e253e168d 100644 --- a/content/handlers/html/box_textarea.c +++ b/content/handlers/html/box_textarea.c @@ -43,24 +43,32 @@ nserror box_textarea_keypress(html_content *html, struct box *box, uint32_t key) struct form_control *gadget = box->gadget; struct textarea *ta = gadget->data.text.ta; struct form* form = box->gadget->form; - struct content *c = (struct content *) html; + struct content *c = (struct content *)html; nserror res = NSERROR_OK; assert(ta != NULL); - if (gadget->type != GADGET_TEXTAREA) { - switch (key) { - case NS_KEY_NL: - case NS_KEY_CR: - if (form) { - res = form_submit(content_get_url(c), - html->bw, - form, - NULL); - } - break; + if (gadget->type == GADGET_TEXTAREA) { + if (textarea_keypress(ta, key)) { + return NSERROR_OK; + } else { + return NSERROR_INVALID; + } + } + + /* non textarea input */ + switch (key) { + case NS_KEY_NL: + case NS_KEY_CR: + if (form) { + res = form_submit(content_get_url(c), + html->bw, + form, + NULL); + } + break; - case NS_KEY_TAB: + case NS_KEY_TAB: { struct form_control *next_input; /* Find next text entry field that is actually @@ -79,9 +87,9 @@ nserror box_textarea_keypress(html_content *html, struct box *box, uint32_t key) textarea_set_caret(next_input->data.text.ta, 0); } } - break; + break; - case NS_KEY_SHIFT_TAB: + case NS_KEY_SHIFT_TAB: { struct form_control *prev_input; /* Find previous text entry field that is actually @@ -100,15 +108,14 @@ nserror box_textarea_keypress(html_content *html, struct box *box, uint32_t key) textarea_set_caret(prev_input->data.text.ta, 0); } } - break; + break; - default: - /* Pass to textarea widget */ - if (!textarea_keypress(ta, key)) { - res = NSERROR_INVALID; - } - break; + default: + /* Pass to textarea widget */ + if (!textarea_keypress(ta, key)) { + res = NSERROR_INVALID; } + break; } return res; -- cgit v1.2.3