summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--textscreen/txt_dropdown.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/textscreen/txt_dropdown.c b/textscreen/txt_dropdown.c
index c9a5d015..a6185a4c 100644
--- a/textscreen/txt_dropdown.c
+++ b/textscreen/txt_dropdown.c
@@ -49,14 +49,29 @@ static int ValidSelection(txt_dropdown_list_t *list)
static int SelectorWindowY(txt_dropdown_list_t *list)
{
+ int result;
+
if (ValidSelection(list))
{
- return list->widget.y - 1 - *list->variable;
+ result = list->widget.y - 1 - *list->variable;
}
else
{
- return list->widget.y - 1 - (list->num_values / 2);
+ result = list->widget.y - 1 - (list->num_values / 2);
+ }
+
+ // Keep dropdown inside the screen.
+
+ if (result < 1)
+ {
+ result = 1;
+ }
+ else if (result + list->num_values > (TXT_SCREEN_H - 3))
+ {
+ result = TXT_SCREEN_H - list->num_values - 3;
}
+
+ return result;
}
// Called when a button in the selector window is pressed