1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Initially place cursor on the current listbox item

Introduce the macros before_widgets and foreach_widget_back. Use the
latter in update_all_widgets instead of foreach_widget so that the
widgets are printed in reverse order, which means that any listbox is
drawn last, which allows it to grab the cursor from the selected button
when the dialogue box is initialised or redrawn.

Requested by Kirk Reiser for great usability with screen readers.
This commit is contained in:
Miciah Dashiel Butler Masters 2006-02-12 17:11:57 +00:00 committed by Miciah Dashiel Butler Masters
parent daad05c055
commit c776fab903
2 changed files with 9 additions and 1 deletions

View File

@ -57,7 +57,9 @@ update_all_widgets(struct dialog_data *dlg_data)
{ {
struct widget_data *widget_data; struct widget_data *widget_data;
foreach_widget(dlg_data, widget_data) { /* Iterate backwards rather than forwards so that listboxes are drawn
* last, which means that they can grab the cursor. Yes, 'tis hacky. */
foreach_widget_back(dlg_data, widget_data) {
display_widget(dlg_data, widget_data); display_widget(dlg_data, widget_data);
} }
} }

View File

@ -131,6 +131,7 @@ void refresh_dialog(struct dialog_data *, dialog_refresh_handler_T handler, void
void select_widget(struct dialog_data *dlg_data, struct widget_data *widget_data); void select_widget(struct dialog_data *dlg_data, struct widget_data *widget_data);
struct widget_data *select_widget_by_id(struct dialog_data *dlg_data, int i); struct widget_data *select_widget_by_id(struct dialog_data *dlg_data, int i);
#define before_widgets(dlg_data) (&(dlg_data)->widgets_data[-1])
#define end_of_widgets(dlg_data) (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets]) #define end_of_widgets(dlg_data) (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets])
#define first_widget(dlg_data) (&(dlg_data)->widgets_data[0]) #define first_widget(dlg_data) (&(dlg_data)->widgets_data[0])
#define last_widget(dlg_data) (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets - 1]) #define last_widget(dlg_data) (&(dlg_data)->widgets_data[(dlg_data)->number_of_widgets - 1])
@ -140,6 +141,11 @@ struct widget_data *select_widget_by_id(struct dialog_data *dlg_data, int i);
(widget_data) != end_of_widgets(dlg_data); \ (widget_data) != end_of_widgets(dlg_data); \
(widget_data)++) (widget_data)++)
#define foreach_widget_back(dlg_data, widget_data) \
for ((widget_data) = last_widget(dlg_data); \
(widget_data) != before_widgets(dlg_data); \
(widget_data)--)
#define is_selected_widget(dlg_data, widget_data) ((widget_data) == selected_widget(dlg_data)) #define is_selected_widget(dlg_data, widget_data) ((widget_data) == selected_widget(dlg_data))
#define add_dlg_end(dlg, n) \ #define add_dlg_end(dlg, n) \