Added support for form with multiple submit buttons.
Forms with multiple submit buttons are rather rare but nevertheless the most popular web page (www.google.com) contains one with the two submit buttons "Google Search" and "I'm Feeling Lucky". So we want to support that - incl. the usual feature to the interpret first button as default button used when the user presses the ENTER key.
This commit is contained in:
parent
e8b4befd1e
commit
47bf797864
|
@ -196,7 +196,7 @@ PROCESS(www_process, "Web browser");
|
||||||
|
|
||||||
AUTOSTART_PROCESSES(&www_process);
|
AUTOSTART_PROCESSES(&www_process);
|
||||||
|
|
||||||
static void CC_FASTCALL formsubmit(struct formattrib *form);
|
static void CC_FASTCALL formsubmit(struct inputattrib *trigger);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* make_window()
|
/* make_window()
|
||||||
|
@ -564,9 +564,8 @@ PROCESS_THREAD(www_process, ev, data)
|
||||||
#if WWW_CONF_FORMS
|
#if WWW_CONF_FORMS
|
||||||
} else {
|
} else {
|
||||||
/* Assume form widget. */
|
/* Assume form widget. */
|
||||||
struct inputattrib *input = (struct inputattrib *)
|
formsubmit((struct inputattrib *)
|
||||||
(((char *)w) - offsetof(struct inputattrib, widget));
|
(((char *)w) - offsetof(struct inputattrib, widget)));
|
||||||
formsubmit(input->formptr);
|
|
||||||
#endif /* WWW_CONF_FORMS */
|
#endif /* WWW_CONF_FORMS */
|
||||||
}
|
}
|
||||||
} else if(ev == ctk_signal_hyperlink_activate) {
|
} else if(ev == ctk_signal_hyperlink_activate) {
|
||||||
|
@ -964,23 +963,36 @@ add_query(char delimiter, char *string)
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static void CC_FASTCALL
|
static void CC_FASTCALL
|
||||||
formsubmit(struct formattrib *form)
|
formsubmit(struct inputattrib *trigger)
|
||||||
{
|
{
|
||||||
struct inputattrib *inputptr;
|
struct inputattrib *input;
|
||||||
|
struct formattrib *form = trigger->formptr;
|
||||||
char delimiter = ISO_questionmark;
|
char delimiter = ISO_questionmark;
|
||||||
|
|
||||||
set_link(form->action);
|
set_link(form->action);
|
||||||
|
|
||||||
for(inputptr = form->nextptr; inputptr != NULL; inputptr = inputptr->nextptr) {
|
/* No button pressed so prepare to look for default button. */
|
||||||
|
if(trigger->widget.type == CTK_WIDGET_TEXTENTRY) {
|
||||||
|
trigger = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(input = form->nextptr; input != NULL; input = input->nextptr) {
|
||||||
char *name;
|
char *name;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
if(inputptr->widget.type == CTK_WIDGET_BUTTON) {
|
if(input->widget.type == CTK_WIDGET_TEXTENTRY) {
|
||||||
name = ((struct submitattrib *)inputptr)->name;
|
name = ((struct textattrib *)input)->name;
|
||||||
value = ((struct submitattrib *)inputptr)->button.text;
|
value = ((struct textattrib *)input)->textentry.text;
|
||||||
} else {
|
} else {
|
||||||
name = ((struct textattrib *)inputptr)->name;
|
/* Consider first button as default button. */
|
||||||
value = ((struct textattrib *)inputptr)->textentry.text;
|
if(trigger == NULL) {
|
||||||
|
trigger = input;
|
||||||
|
}
|
||||||
|
if(input != trigger) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
name = ((struct submitattrib *)input)->name;
|
||||||
|
value = ((struct submitattrib *)input)->button.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_query(delimiter, name);
|
add_query(delimiter, name);
|
||||||
|
|
Loading…
Reference in a new issue