diff --git a/src/pc/djui/djui_panel.c b/src/pc/djui/djui_panel.c index e51f48f88..400ff1e81 100644 --- a/src/pc/djui/djui_panel.c +++ b/src/pc/djui/djui_panel.c @@ -18,16 +18,15 @@ bool djui_panel_is_active(void) { } struct DjuiBase* djui_panel_find_first_interactable(struct DjuiBaseChild* child) { - struct DjuiBaseChild *i = child; - while (i) { - if (i->base->interactable && i->base->interactable->enabled) { - return i->base; + while (child) { + if (child->base->interactable && child->base->interactable->enabled) { + return child->base; } - struct DjuiBase* check = djui_panel_find_first_interactable(i->base->child); + struct DjuiBase* check = djui_panel_find_first_interactable(child->base->child); if (check) { return check; } - i = i->next; + child = child->next; } - + // If we didn't find anything at all. Return NULL. LOG_ERROR("Failed to find a interactable for child %p.", child); return NULL; diff --git a/src/pc/djui/djui_selectionbox.c b/src/pc/djui/djui_selectionbox.c index 4db58c2c3..c06c8c883 100644 --- a/src/pc/djui/djui_selectionbox.c +++ b/src/pc/djui/djui_selectionbox.c @@ -76,6 +76,10 @@ struct DjuiSelectionbox* djui_selectionbox_create(struct DjuiBase* parent, const struct DjuiSelectionbox* selectionbox = calloc(1, sizeof(struct DjuiSelectionbox)); struct DjuiBase* base = &selectionbox->base; + if (*value >= choiceCount) { + *value = choiceCount - 1; + } + selectionbox->value = value; selectionbox->choices = calloc(choiceCount, sizeof(char*)); for (int i = 0; i < choiceCount; i++) {