From 23a4e77016aa22c9b48b72cdf902e17c09085330 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Mon, 13 Oct 2025 13:37:01 +0000 Subject: [PATCH] inherit git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@310 b9cfdab3-6d41-4d17-bbe4-086880011989 --- src/core.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index c18958f..75dd9a3 100644 --- a/src/core.c +++ b/src/core.c @@ -349,11 +349,24 @@ void MwVaListApply(MwWidget handle, va_list va) { } } +static void inherit_text(MwWidget handle, const char* key, const char* default_value) { + const char* text; + MwWidget h = handle; + while(h != NULL) { + if((text = MwGetText(h, key)) != NULL) { + MwSetText(handle, key, text); + return; + } + h = h->parent; + } + MwSetText(handle, key, default_value); +} + void MwSetDefault(MwWidget handle) { MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask); - MwSetText(handle, MwNbackground, MwDefaultBackground); - MwSetText(handle, MwNforeground, MwDefaultForeground); + inherit_text(handle, MwNbackground, MwDefaultBackground); + inherit_text(handle, MwNforeground, MwDefaultForeground); } void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data) {