textscreen: Allow cycling through tables with tab key.

Most GUI toolkits allow using the tab key to cycle through windows, so
support this (and shift-tab to cycle backwards) just for completeness.
This commit is contained in:
Simon Howard 2015-07-11 17:13:20 -04:00
parent 7a2f14efc3
commit 6878629637
2 changed files with 27 additions and 3 deletions

View file

@ -402,7 +402,8 @@ static int TXT_ScrollPaneKeyPress(TXT_UNCAST_ARG(scrollpane), int key)
if ((key == KEY_UPARROW || key == KEY_DOWNARROW
|| key == KEY_LEFTARROW || key == KEY_RIGHTARROW
|| key == KEY_PGUP || key == KEY_PGDN)
|| key == KEY_PGUP || key == KEY_PGDN
|| key == KEY_TAB)
&& scrollpane->child->widget_class == &txt_table_class)
{
if (PageSelectedWidget(scrollpane, key))

View file

@ -500,6 +500,29 @@ static int TXT_TableKeyPress(TXT_UNCAST_ARG(table), int key)
}
}
if (key == KEY_TAB)
{
int dir;
int i;
dir = TXT_GetModifierState(TXT_MOD_SHIFT) ? -1 : 1;
// Cycle through all widgets until we find one that can be selected.
for (i = table->selected_y * table->columns + table->selected_x + dir;
i >= 0 && i < table->num_widgets;
i += dir)
{
if (IsActualWidget(table->widgets[i])
&& TXT_SelectableWidget(table->widgets[i]))
{
ChangeSelection(table, i % table->columns, i / table->columns);
return 1;
}
}
return 0;
}
if (key == KEY_DOWNARROW)
{
int new_x, new_y;
@ -518,7 +541,7 @@ static int TXT_TableKeyPress(TXT_UNCAST_ARG(table), int key)
return 1;
}
}
}
}
if (key == KEY_UPARROW)
@ -539,7 +562,7 @@ static int TXT_TableKeyPress(TXT_UNCAST_ARG(table), int key)
return 1;
}
}
}
}
if (key == KEY_LEFTARROW)