diff --git a/src/Key/KeyEventSink.cpp b/src/Key/KeyEventSink.cpp index 1099f053..aed2489c 100644 --- a/src/Key/KeyEventSink.cpp +++ b/src/Key/KeyEventSink.cpp @@ -1,3 +1,4 @@ +#include "FanyUtils.h" #include "Private.h" #include "Globals.h" #include "SampleIME.h" @@ -8,6 +9,9 @@ #include "SampleIMEBaseStructure.h" #include "fmt/format.h" #include "fmt/xchar.h" +#include +#include +#include // 0xF003, 0xF004 are the keys that the touch keyboard sends for next/previous #define THIRDPARTY_NEXTPAGE static_cast(0xF003) @@ -345,6 +349,24 @@ STDAPI CSampleIME::OnKeyDown(ITfContext *pContext, WPARAM wParam, LPARAM lParam, if (needInvokeKeyHandler) { + TF_STATUS tfStatus; + if (SUCCEEDED(pContext->GetStatus(&tfStatus))) + { + if (tfStatus.dwDynamicFlags & TF_SD_READONLY) + { + FanyUtuils::SendKeys(boost::lexical_cast(wch)); +#ifdef FANY_DEBUG + Global::LogMessageW(L"pContext is read-only"); +#endif + } + else + { +#ifdef FANY_DEBUG + Global::LogMessageW(L"pContext is editable"); +#endif + } + } + _InvokeKeyHandler(pContext, code, wch, (DWORD)lParam, KeystrokeState); } } diff --git a/src/Key/KeyHandler.cpp b/src/Key/KeyHandler.cpp index 51bcb31f..24975b84 100644 --- a/src/Key/KeyHandler.cpp +++ b/src/Key/KeyHandler.cpp @@ -7,6 +7,8 @@ #include "SampleIMEBaseStructure.h" #include #include "Utils/FanyUtils.h" +#include "fmt/format.h" +#include "fmt/xchar.h" ////////////////////////////////////////////////////////////////////// // @@ -661,8 +663,10 @@ HRESULT CSampleIME::_InvokeKeyHandler(_In_ ITfContext *pContext, UINT code, WCHA // we'll insert a char ourselves in place of this keystroke pEditSession = new (std::nothrow) CKeyHandlerEditSession(this, pContext, code, wch, keyState); + Global::LogMessageW(L"fanyfull01 _InvokeKeyHandler"); if (pEditSession == nullptr) { + Global::LogMessageW(L"fanyfull02 _InvokeKeyHandler"); goto Exit; } @@ -672,6 +676,12 @@ HRESULT CSampleIME::_InvokeKeyHandler(_In_ ITfContext *pContext, UINT code, WCHA // Do not specify TF_ES_SYNC so edit session is not invoked on WinWord // hr = pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr); + if (FAILED(hr)) + { + Global::LogMessageW(L"fanyfull03 _InvokeKeyHandler"); + } + + Global::LogMessageW(fmt::format(L"fanyfull04 _InvokeKeyHandler hr: {}", hr).c_str()); pEditSession->Release();