[ftb]: also toggle punc status when cn/en state changed
This commit is contained in:
1 parent
800d87ce7c
commit
10fa4e6edf
4 files changed
+45
-13
No files matched your search
@@ -108,16 +108,6 @@ void WorkerThread()
|
||||
break;
|
||||
}
|
||||
|
||||
// case TaskType::IMEActivation: {
|
||||
// PostMessage(::global_hwnd, WM_IMEACTIVATE, 0, 0);
|
||||
// break;
|
||||
// }
|
||||
|
||||
// case TaskType::IMEDeactivation: {
|
||||
// PostMessage(::global_hwnd, WM_IMEDEACTIVATE, 0, 0);
|
||||
// break;
|
||||
// }
|
||||
|
||||
case TaskType::IMESwitch: {
|
||||
::ReadDataFromNamedPipe(0b000001);
|
||||
PostMessage(::global_hwnd, WM_IMESWITCH, Global::Keycode, 0);
|
||||
|
||||
@@ -946,6 +946,45 @@ void UpdateFtbCnEnState(ComPtr<ICoreWebView2> webview, int cnEnState)
|
||||
script.append(L"document.getElementById('cn').style.display = 'none';");
|
||||
script.append(L"document.getElementById('en').style.display = 'flex';");
|
||||
|
||||
webview->ExecuteScript(script.c_str(), nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 更新 floating toolbar 窗口的中英文切换状态和标点切换状态
|
||||
*
|
||||
* @param webview
|
||||
* @param cnEnState 1: 中文, 0: 英文
|
||||
*/
|
||||
void UpdateFtbCnEnAndPuncState(ComPtr<ICoreWebView2> webview, int cnEnState)
|
||||
{
|
||||
if (webview == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cnEnState == 1)
|
||||
{
|
||||
std::wstring script;
|
||||
script.reserve(256);
|
||||
|
||||
script.append(L"document.getElementById('cn').style.display = 'flex';");
|
||||
script.append(L"document.getElementById('en').style.display = 'none';");
|
||||
script.append(L"document.getElementById('puncCn').style.display = 'flex';");
|
||||
script.append(L"document.getElementById('puncEn').style.display = 'none';");
|
||||
|
||||
webview->ExecuteScript(script.c_str(), nullptr);
|
||||
}
|
||||
else if (cnEnState == 0)
|
||||
{
|
||||
std::wstring script;
|
||||
script.reserve(256);
|
||||
|
||||
script.append(L"document.getElementById('cn').style.display = 'none';");
|
||||
script.append(L"document.getElementById('en').style.display = 'flex';");
|
||||
script.append(L"document.getElementById('puncCn').style.display = 'none';");
|
||||
script.append(L"document.getElementById('puncEn').style.display = 'flex';");
|
||||
|
||||
webview->ExecuteScript(script.c_str(), nullptr);
|
||||
}
|
||||
}
|
||||
@@ -82,4 +82,5 @@ inline ComPtr<ICoreWebView2Controller2> webviewController2FtbWnd;
|
||||
inline std::wstring HTMLStringFtbWnd = LR"()";
|
||||
|
||||
void InitWebviewFtbWnd(HWND hwnd);
|
||||
void UpdateFtbCnEnState(ComPtr<ICoreWebView2> webview, int cnEnState);
|
||||
void UpdateFtbCnEnState(ComPtr<ICoreWebView2> webview, int cnEnState);
|
||||
void UpdateFtbCnEnAndPuncState(ComPtr<ICoreWebView2> webview, int cnEnState);
|
||||
@@ -393,11 +393,13 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
||||
{
|
||||
if (wParam == 0) // 此时是英文状态
|
||||
{
|
||||
UpdateFtbCnEnState(::webviewFtbWnd, 0); // 更新 floating toolbar 的中英文状态为英文
|
||||
/* 更新 floating toolbar 的中英文状态为英文,同时更新标点的全角和半角状态 */
|
||||
UpdateFtbCnEnAndPuncState(::webviewFtbWnd, 0);
|
||||
}
|
||||
else // 此时是中文状态
|
||||
{
|
||||
UpdateFtbCnEnState(::webviewFtbWnd, 1); // 更新 floating toolbar 的中英文状态为中文
|
||||
/* 更新 floating toolbar 的中英文状态为中文,同时更新标点的全角和半角状态 */
|
||||
UpdateFtbCnEnAndPuncState(::webviewFtbWnd, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user