aboutsummaryrefslogtreecommitdiff
path: root/src/osx/gui/InputMethod.mm
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-10-21 18:42:58 +0800
committercrupest <crupest@outlook.com>2021-10-21 18:42:58 +0800
commit411027e66401d363abb6217b59b2b695b856c917 (patch)
tree9bf75a1a5ad4da9428909e3582f9b9a9a8db03aa /src/osx/gui/InputMethod.mm
parent72fc892792565ef39fcae6b7d2a19006dc3a3238 (diff)
downloadcru-411027e66401d363abb6217b59b2b695b856c917.tar.gz
cru-411027e66401d363abb6217b59b2b695b856c917.tar.bz2
cru-411027e66401d363abb6217b59b2b695b856c917.zip
...
Diffstat (limited to 'src/osx/gui/InputMethod.mm')
-rw-r--r--src/osx/gui/InputMethod.mm17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/osx/gui/InputMethod.mm b/src/osx/gui/InputMethod.mm
index e6105354..2331d8b7 100644
--- a/src/osx/gui/InputMethod.mm
+++ b/src/osx/gui/InputMethod.mm
@@ -32,6 +32,19 @@ void OsxInputMethodContextPrivate::PerformSel(SEL sel) {
[window_->p_->GetNSWindow() performSelector:sel];
}
+void OsxInputMethodContextPrivate::Activate() {
+ if (!window_->p_->GetNSWindow()) return;
+ auto input_context = [[window_->p_->GetNSWindow() contentView] inputContext];
+ Ensures(input_context);
+ [input_context activate];
+}
+
+void OsxInputMethodContextPrivate::Deactivate() {
+ if (!window_->p_->GetNSWindow()) return;
+ auto input_context = [[window_->p_->GetNSWindow() contentView] inputContext];
+ Ensures(input_context);
+ [input_context deactivate];
+}
}
OsxInputMethodContext::OsxInputMethodContext(OsxWindow* window)
@@ -41,9 +54,9 @@ OsxInputMethodContext::OsxInputMethodContext(OsxWindow* window)
OsxInputMethodContext::~OsxInputMethodContext() {}
-void OsxInputMethodContext::EnableIME() { [[NSTextInputContext currentInputContext] activate]; }
+void OsxInputMethodContext::EnableIME() { p_->Activate(); }
-void OsxInputMethodContext::DisableIME() { [[NSTextInputContext currentInputContext] deactivate]; }
+void OsxInputMethodContext::DisableIME() { p_->Deactivate(); }
bool OsxInputMethodContext::ShouldManuallyDrawCompositionText() { return true; }