From 9de746e0a00ad6055a0d4797cd66c1b62b4cc5d6 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 8 Apr 2004 23:46:41 +0000 Subject: [project @ 2004-04-08 23:46:41 by jmb] Improve keypress handling in form text boxes. Note: Not yet implemented for textareas as these need more work anyway. svn path=/import/netsurf/; revision=740 --- desktop/browser.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'desktop/browser.c') diff --git a/desktop/browser.c b/desktop/browser.c index 009810a04..19175bfc4 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -1193,8 +1193,74 @@ void browser_window_input_callback(struct browser_window *bw, char key, void *p) browser_form_submit(bw, form, 0); } else if (key == 9) { /* Tab */ - /* TODO: tabbing between inputs */ + struct form_control* next_input; + for (next_input = input->gadget->next; + next_input != 0 && next_input->type != GADGET_TEXTBOX && + next_input->type != GADGET_TEXTAREA && + next_input->type != GADGET_PASSWORD && + next_input->type != GADGET_FILE; + next_input = next_input->next) + ; + if (!next_input) return; + + input = next_input->box; + text_box = input->children->children; + box_coords(input, &actual_x, &actual_y); + text_box->x = 0; + input->gadget->caret_char_offset = 0; + browser_window_place_caret(bw, + (int)(actual_x + text_box->x), + (int)(actual_y + text_box->y), + text_box->height, + browser_window_input_callback, input); + gui_window_redraw(bw->window, + actual_x, + actual_y, + actual_x + input->width, + actual_y + input->height); + return; + } else if (key == 11) { + /* Shift+Tab */ + struct form_control* prev_input; + for (prev_input = input->gadget->prev; + prev_input != 0 && prev_input->type != GADGET_TEXTBOX && + prev_input->type != GADGET_TEXTAREA && + prev_input->type != GADGET_PASSWORD && + prev_input->type != GADGET_FILE; + prev_input = prev_input->prev) + ; + if (!prev_input) return; + + input = prev_input->box; + text_box = input->children->children; + box_coords(input, &actual_x, &actual_y); + text_box->x = 0; + input->gadget->caret_char_offset = 0; + browser_window_place_caret(bw, + (int)(actual_x + text_box->x), + (int)(actual_y + text_box->y), + text_box->height, + browser_window_input_callback, input); + gui_window_redraw(bw->window, + actual_x, + actual_y, + actual_x + input->width, + actual_y + input->height); return; + } else if (key == 21) { + /* Ctrl+U */ + xfree(text_box->text); + text_box->text = xcalloc(0, sizeof(char)); + text_box->length = 0; + xfree(input->gadget->value); + input->gadget->value = xcalloc(0, sizeof(char)); + char_offset = 0; + } else if (key == 26) { + /* Ctrl+Left */ + char_offset = 0; + } else if (key == 27) { + /* Ctrl+Right */ + char_offset = text_box->length; } else if (key == 28 && (unsigned int)char_offset != text_box->length) { /* Right cursor -> */ char_offset++; -- cgit v1.2.3