From fca421e2047a55f3cf575c92943c1116ec58da3c Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 6 Nov 2019 23:13:20 +0000 Subject: remove user warning and propogate error return --- content/handlers/html/box_textarea.c | 59 ++++++++++++++++---------------- content/handlers/html/box_textarea.h | 4 +-- content/handlers/html/html_interaction.c | 11 +++--- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/content/handlers/html/box_textarea.c b/content/handlers/html/box_textarea.c index f0ba9f9de..8b4fdf954 100644 --- a/content/handlers/html/box_textarea.c +++ b/content/handlers/html/box_textarea.c @@ -38,13 +38,13 @@ #include "html/form_internal.h" -bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key) +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; - nserror res; + nserror res = NSERROR_OK; assert(ta != NULL); @@ -57,12 +57,8 @@ bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key) html->bw, form, NULL); - if (res != NSERROR_OK) { - guit->misc->warning(messages_get_errorcode(res), NULL); - } - } - return true; + break; case NS_KEY_TAB: { @@ -70,20 +66,20 @@ bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key) /* Find next text entry field that is actually * displayed (i.e. has an associated box) */ for (next_input = gadget->next; - next_input && - ((next_input->type != GADGET_TEXTBOX && - next_input->type != GADGET_TEXTAREA && - next_input->type != GADGET_PASSWORD) || - !next_input->box); - next_input = next_input->next) + next_input && + ((next_input->type != GADGET_TEXTBOX && + next_input->type != GADGET_TEXTAREA && + next_input->type != GADGET_PASSWORD) || + !next_input->box); + next_input = next_input->next) ; - if (!next_input) - return true; - textarea_set_caret(ta, -1); - textarea_set_caret(next_input->data.text.ta, 0); + if (next_input != NULL) { + textarea_set_caret(ta, -1); + textarea_set_caret(next_input->data.text.ta, 0); + } } - return true; + break; case NS_KEY_SHIFT_TAB: { @@ -91,28 +87,31 @@ bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key) /* Find previous text entry field that is actually * displayed (i.e. has an associated box) */ for (prev_input = gadget->prev; - prev_input && - ((prev_input->type != GADGET_TEXTBOX && - prev_input->type != GADGET_TEXTAREA && - prev_input->type != GADGET_PASSWORD) || - !prev_input->box); - prev_input = prev_input->prev) + prev_input && + ((prev_input->type != GADGET_TEXTBOX && + prev_input->type != GADGET_TEXTAREA && + prev_input->type != GADGET_PASSWORD) || + !prev_input->box); + prev_input = prev_input->prev) ; - if (!prev_input) - return true; - textarea_set_caret(ta, -1); - textarea_set_caret(prev_input->data.text.ta, 0); + if (prev_input != NULL) { + textarea_set_caret(ta, -1); + textarea_set_caret(prev_input->data.text.ta, 0); + } } - return true; + break; default: /* Pass to textarea widget */ + if (!textarea_keypress(ta, key)) { + res = NSERROR_INVALID; + } break; } } - return textarea_keypress(ta, key); + return res; } diff --git a/content/handlers/html/box_textarea.h b/content/handlers/html/box_textarea.h index 822fc8b10..219ef2301 100644 --- a/content/handlers/html/box_textarea.h +++ b/content/handlers/html/box_textarea.h @@ -45,8 +45,8 @@ bool box_textarea_create_textarea(struct html_content *html, * \param html html content object * \param box box with textarea widget * \param key keypress - * \return true iff keypress handled + * \return NSERROR_OK iff keypress handled */ -bool box_textarea_keypress(struct html_content *html, struct box *box, uint32_t key); +nserror box_textarea_keypress(struct html_content *html, struct box *box, uint32_t key); #endif diff --git a/content/handlers/html/html_interaction.c b/content/handlers/html/html_interaction.c index d31ad1d06..1eedf1b8f 100644 --- a/content/handlers/html/html_interaction.c +++ b/content/handlers/html/html_interaction.c @@ -1119,16 +1119,17 @@ bool html_keypress(struct content *c, uint32_t key) { html_content *html = (html_content *) c; struct selection *sel = &html->sel; - struct box *box; switch (html->focus_type) { case HTML_FOCUS_CONTENT: - box = html->focus_owner.content; - return content_keypress(box->object, key); + return content_keypress(html->focus_owner.content->object, key); case HTML_FOCUS_TEXTAREA: - box = html->focus_owner.textarea; - return box_textarea_keypress(html, box, key); + if (box_textarea_keypress(html, html->focus_owner.textarea, key) == NSERROR_OK) { + return true; + } else { + return false; + } default: /* Deal with it below */ -- cgit v1.2.3