diff --git a/dvx/widgets/widgetEvent.c b/dvx/widgets/widgetEvent.c index a0c4ace..942c026 100644 --- a/dvx/widgets/widgetEvent.c +++ b/dvx/widgets/widgetEvent.c @@ -614,6 +614,16 @@ void widgetOnPaint(WindowT *win, RectT *dirtyArea) { widgetLayoutChildren(root, &ctx->font); } + // Auto-focus first focusable widget if nothing has focus yet + if (!sFocusedWidget) { + WidgetT *first = widgetFindNextFocusable(root, NULL); + + if (first) { + first->focused = true; + sFocusedWidget = first; + } + } + // Paint widget tree (clip rect limits drawing to visible area) wgtPaint(root, &cd, &ctx->blitOps, &ctx->font, &ctx->colors);