From 69865a54f61cd4c705cc31adb5b809dfbf5b7f06 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 18 Mar 2026 00:36:15 -0500 Subject: [PATCH] First focusable widget now focused on window initial paint. --- dvx/widgets/widgetEvent.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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);