From 32aa6f116acc6e3e20a1ec76cef45b29f7005ad7 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 17 Oct 2025 12:06:14 +0800 Subject: Remove String stage 1. --- demos/InputMethod/main.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'demos/InputMethod') diff --git a/demos/InputMethod/main.cpp b/demos/InputMethod/main.cpp index 4ea5ab72..3598626d 100644 --- a/demos/InputMethod/main.cpp +++ b/demos/InputMethod/main.cpp @@ -11,6 +11,8 @@ #include "cru/platform/gui/UiApplication.h" #include "cru/platform/gui/Window.h" +#include + using namespace cru; using namespace cru::platform; using namespace cru::platform::graphics; @@ -33,7 +35,7 @@ class DemoWindow { std::unique_ptr window_; std::unique_ptr prompt_text_layout_; std::unique_ptr committed_text_layout_; - String committed_text_; + std::string committed_text_; CompositionText composition_text_; }; @@ -47,11 +49,11 @@ DemoWindow::DemoWindow(IUiApplication* application, DemoBrushes* brushes, prompt_text_layout_ = graphics_factory->CreateTextLayout(font, - u"Ctrl+1: Enable IME\n" - u"Ctrl+2: Disable IME\n" - u"Ctrl+3: Complete composition.\n" - u"Ctrl+4: Cancel composition."); - committed_text_layout_ = graphics_factory->CreateTextLayout(font, u""); + "Ctrl+1: Enable IME\n" + "Ctrl+2: Disable IME\n" + "Ctrl+3: Complete composition.\n" + "Ctrl+4: Cancel composition."); + committed_text_layout_ = graphics_factory->CreateTextLayout(font, ""); auto update_text_layout_width = [this](const Size& size) { prompt_text_layout_->SetMaxWidth(size.width); @@ -102,7 +104,7 @@ DemoWindow::DemoWindow(IUiApplication* application, DemoBrushes* brushes, window_->KeyDownEvent()->AddHandler([this](const NativeKeyEventArgs& args) { auto input_method_context = window_->GetInputMethodContext(); - if (args.modifier & KeyModifiers::ctrl) { + if (args.modifier & KeyModifiers::Ctrl) { switch (args.key) { case KeyCode::N1: input_method_context->EnableIME(); @@ -136,7 +138,7 @@ DemoWindow::DemoWindow(IUiApplication* application, DemoBrushes* brushes, }; input_method_context->TextEvent()->AddHandler( - [this, update_state](const StringView& c) { + [this, update_state](const std::string& c) { committed_text_ += c; update_state(); }); @@ -168,7 +170,7 @@ int main() { graphics_factory->CreateSolidColorBrush(colors::green), graphics_factory->CreateSolidColorBrush(colors::blue)}; - std::shared_ptr font = graphics_factory->CreateFont(String{}, 30); + std::shared_ptr font = graphics_factory->CreateFont({}, 30); DemoWindow window1(application, &brushes, font); DemoWindow window2(application, &brushes, font); -- cgit v1.2.3