[project @ 2003-09-29 02:47:11 by jmb]

Cursor keys and Enter in forms

svn path=/import/netsurf/; revision=331
This commit is contained in:
John Mark Bell 2003-09-29 02:47:11 +00:00
parent 73f7db2a75
commit 20ae4bff71
2 changed files with 37 additions and 3 deletions

View File

@ -732,7 +732,7 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void
text_box->length = 0;
text_box->width = UNKNOWN_WIDTH;
char_offset--;
}
}
} else {
/* delete a character */
memmove(text_box->text + char_offset - 1,
@ -742,6 +742,20 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void
text_box->width = UNKNOWN_WIDTH;
char_offset--;
}
} else if (key == 28 && char_offset != text_box->length) {
/* Right cursor -> */
char_offset++;
} else if (key == 29 && char_offset != 0) {
/* Left cursor <- */
char_offset--;
} else if (key == 30) {
/* Up Cursor */
/* TODO */
return;
} else if (key == 31) {
/* Down cursor */
/* TODO */
return;
} else {
return;
}
@ -788,7 +802,7 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void
if (!t->next) assert(ic->last == t);
}
} */
if (text_box->length < char_offset) {
/* the text box has been split and the caret is in the second part */
char_offset -= (text_box->length + 1); /* +1 for the space */
@ -862,6 +876,7 @@ void browser_window_input_callback(struct browser_window *bw, char key, void *p)
int char_offset = input->gadget->caret_char_offset;
int pixel_offset;
unsigned long actual_x, actual_y;
struct form* form = input->gadget->form;
box_coords(input, &actual_x, &actual_y);
@ -895,6 +910,20 @@ void browser_window_input_callback(struct browser_window *bw, char key, void *p)
text_box->length--;
input->gadget->value[text_box->length] = 0;
char_offset--;
} else if (key == 10 || key == 13) {
/* Return/Enter hit */
browser_form_submit(bw, form);
/*TODO: remove caret from new page */
} else if (key == 9) {
/* Tab */
/* TODO: tabbing between inputs */
return;
} else if (key == 28 && char_offset != text_box->length) {
/* Right cursor -> */
char_offset++;
} else if (key == 29 && char_offset != 0) {
/* Left cursor <- */
char_offset--;
} else {
return;
}

View File

@ -1364,9 +1364,14 @@ void ro_gui_keypress(wimp_key* key)
{
gui_window* g;
if (key->i == -1 && key->c < 256) {
if (key->i == -1 && (key->c < 256 || (key->c >= 396 && key->c <= 399))) {
g = ro_lookup_gui_from_w(key->w);
if (g) {
/* Munge cursor keys into unused control chars */
if (key->c == 396) key->c = 29; /* Left */
else if (key->c == 397) key->c = 28; /* Right */
else if (key->c == 398) key->c = 31; /* Down */
else if (key->c == 399) key->c = 30; /* Up */
browser_window_key_press(g->data.browser.bw, (char) key->c);
return;
}