summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/browser.c68
-rw-r--r--render/form.c1
-rw-r--r--render/form.h1
-rw-r--r--riscos/window.c9
4 files changed, 77 insertions, 2 deletions
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++;
diff --git a/render/form.c b/render/form.c
index 8f18d44ae..c542efd3e 100644
--- a/render/form.c
+++ b/render/form.c
@@ -31,6 +31,7 @@ void form_add_control(struct form *form, struct form_control *control)
if (form->controls) {
assert(form->last_control);
form->last_control->next = control;
+ control->prev = form->last_control;
control->next = 0;
form->last_control = control;
} else {
diff --git a/render/form.h b/render/form.h
index 0063df790..b064e9750 100644
--- a/render/form.h
+++ b/render/form.h
@@ -67,6 +67,7 @@ struct form_control {
int selected;
} radio;
} data;
+ struct form_control *prev; /**< Previous control in this form */
struct form_control *next; /**< Next control in this form. */
};
diff --git a/riscos/window.c b/riscos/window.c
index 5237373c7..1abd994fe 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -767,7 +767,14 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
if (!toolbar) {
int c = key;
/* Munge cursor keys into unused control chars */
- if (c == 396) c = 29; /* Left */
+ /* We can't map on to any of: 3,8,10,13,21,22 or 24
+ * That leaves 1,2,4-7,11,12,14-20,23,25-31 and 129-159
+ */
+ if (c == 394) c = 9; /* Tab */
+ else if (c == 410) c = 11; /* Shift+Tab */
+ else if (c == 428) c = 26; /* Ctrl+Left */
+ else if (c == 429) c = 27; /* Ctrl+Right*/
+ else if (c == 396) c = 29; /* Left */
else if (c == 397) c = 28; /* Right */
else if (c == 398) c = 31; /* Down */
else if (c == 399) c = 30; /* Up */