--- a/ui/winui/text.cpp Sun Nov 10 15:30:46 2024 +0100 +++ b/ui/winui/text.cpp Mon Nov 11 20:45:34 2024 +0100 @@ -56,7 +56,9 @@ UiObject* current = uic_current_obj(obj); // create textarea and toolkit wrapper - RichEditBox textarea = RichEditBox(); + TextBox textarea = TextBox(); + textarea.AcceptsReturn(true); + ScrollViewer::SetVerticalScrollBarVisibility(textarea, ScrollBarVisibility::Auto); UIElement elm = textarea; UiWidget* widget = new UiWidget(elm); ui_context_add_widget_destructor(current->ctx, widget); @@ -97,14 +99,46 @@ } +// -------------------------- getter/setter for textarea UiText -------------------------- +char* ui_wtext_get(UiText *text, std::wstring &value) { + if (text->value.ptr) { + text->value.free(text->value.ptr); + } + + text->value.ptr = wchar2utf8(value.c_str(), value.length()); + text->value.free = free; + + return text->value.ptr; +} + +std::wstring ui_wtext_set(UiText *text, const char* value) { + if (text->value.ptr) { + text->value.free(text->value.ptr); + } + + text->value.ptr = _strdup(value); + text->value.free = free; + + int len; + wchar_t* wstr = str2wstr(value, &len); + std::wstring s(wstr); + free(wstr); + + return s; +} extern "C" char* ui_textarea_get(UiText *text) { - return NULL; + UiWidget* widget = (UiWidget*)text->obj; + TextBox box = widget->uielement.as<TextBox>(); + std::wstring wstr(box.Text()); + return ui_wtext_get(text, wstr); } extern "C" void ui_textarea_set(UiText *text, const char *newvalue) { - + UiWidget* widget = (UiWidget*)text->obj; + TextBox box = widget->uielement.as<TextBox>(); + box.Text(ui_wtext_set(text, newvalue)); } extern "C" char* ui_textarea_getsubstr(UiText *text, int begin, int end) {