mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-04 16:44:14 +03:00
[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
This commit is contained in:
parent
13f1dde4d9
commit
9de746e0a0
@ -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++;
|
||||
|
@ -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 {
|
||||
|
@ -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. */
|
||||
};
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user