diff options
author | crupest <crupest@outlook.com> | 2020-09-15 16:55:03 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-09-15 16:55:03 +0800 |
commit | c9f3ec5f3a04d658194a4b8bfef9ff897985e2f1 (patch) | |
tree | f643761d09fbbf0d3630a82bcdd1b2334e898f02 /src | |
parent | 463995e0aa36bac5a70b661eeb05a9f617958f18 (diff) | |
download | cru-c9f3ec5f3a04d658194a4b8bfef9ff897985e2f1.tar.gz cru-c9f3ec5f3a04d658194a4b8bfef9ff897985e2f1.tar.bz2 cru-c9f3ec5f3a04d658194a4b8bfef9ff897985e2f1.zip |
...
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/UiHost.cpp | 10 | ||||
-rw-r--r-- | src/ui/controls/TextBlock.cpp | 6 | ||||
-rw-r--r-- | src/ui/controls/TextControlService.hpp | 6 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/ui/UiHost.cpp b/src/ui/UiHost.cpp index 5db113bf..5451ebce 100644 --- a/src/ui/UiHost.cpp +++ b/src/ui/UiHost.cpp @@ -3,6 +3,7 @@ #include "RoutedEventDispatch.hpp" #include "cru/common/Logger.hpp" #include "cru/platform/graph/Painter.hpp" +#include "cru/platform/native/InputMethod.hpp" #include "cru/platform/native/UiApplication.hpp" #include "cru/platform/native/Window.hpp" #include "cru/ui/Window.hpp" @@ -98,10 +99,15 @@ UiHost::UiHost(Window* window) mouse_hover_control_(nullptr), focus_control_(window), mouse_captured_control_(nullptr) { - native_window_resolver_ = - IUiApplication::GetInstance()->CreateWindow(nullptr); + const auto ui_application = IUiApplication::GetInstance(); + native_window_resolver_ = ui_application->CreateWindow(nullptr); const auto native_window = native_window_resolver_->Resolve(); + + auto input_method_context = + ui_application->GetInputMethodManager()->GetContext(native_window); + input_method_context->DisableIME(); + window->ui_host_ = this; root_render_object_ = std::make_unique<render::WindowRenderObject>(this); diff --git a/src/ui/controls/TextBlock.cpp b/src/ui/controls/TextBlock.cpp index 7f7ee38b..9ce99ab6 100644 --- a/src/ui/controls/TextBlock.cpp +++ b/src/ui/controls/TextBlock.cpp @@ -30,12 +30,10 @@ render::RenderObject* TextBlock::GetRenderObject() const { return text_render_object_.get(); } -std::u16string TextBlock::GetText() const { - return text_render_object_->GetText(); -} +std::u16string TextBlock::GetText() const { return service_->GetText(); } void TextBlock::SetText(std::u16string text) { - text_render_object_->SetText(std::move(text)); + service_->SetText(std::move(text)); } gsl::not_null<render::TextRenderObject*> TextBlock::GetTextRenderObject() { diff --git a/src/ui/controls/TextControlService.hpp b/src/ui/controls/TextControlService.hpp index c9b4066c..5e423d7d 100644 --- a/src/ui/controls/TextControlService.hpp +++ b/src/ui/controls/TextControlService.hpp @@ -357,6 +357,7 @@ class TextControlService : public Object { if (window == nullptr) return; input_method_context_ = GetUiApplication()->GetInputMethodManager()->GetContext(window); + input_method_context_->EnableIME(); auto sync = [this](std::nullptr_t) { this->SyncTextRenderObject(); }; input_method_context_->CompositionStartEvent()->AddHandler( [this](std::nullptr_t) { this->DeleteSelectedText(); }); @@ -373,7 +374,10 @@ class TextControlService : public Object { void LoseFocusHandler(event::FocusChangeEventArgs& args) { if (!args.IsWindow()) this->AbortSelection(); - input_method_context_.reset(); + if (input_method_context_) { + input_method_context_->DisableIME(); + input_method_context_.reset(); + } SyncTextRenderObject(); } |