帮助理解TSF和Excel焦点行为 [英] Help understanding TSF and Excel focus behaviour

查看:276
本文介绍了帮助理解TSF和Excel焦点行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发基于文本服务框架(TSF)的键盘输入法(现在是日语)。 ITfTextInputProcessorEx实现安装线程管理器事件接收器(ITfThreadMgrEventSink)以侦听对哪个文档管理器具有焦点的更改。
如果重点文档管理器发生更改(或焦点丢失),我想终止任何未完成的合成。我注意到在Microsoft Excel中键入一些有趣的行为。


例如,如果我选择一个单元格,请按'k',然后我的IME将启动一个合成并插入一个'k'。然而,在此之后,我看到ITfThreadMgrEventSink :: OnSetFocus被调用两次:一次使用pdimFocus = NULL并且pdimPrevFocus =< doc mgr>,
,第二次使用pdimFocus =< doc mgr>和pdimPrevFocus = NULL。所以它失去了焦点并立即重新获得它。然后,只要单元格处于编辑模式,焦点就会保留(因此在第一次输入单元格时会暂时丢失)。


我可以确认(通过调试)这也发生在Microsoft IME和Google Japanese Input上。但是,谷歌日语输入通常似乎忽略OnSetFocus(NULL,...)除了更新其UI之外的任何东西(它的源代码是打开的,因此很容易确认
),所以它处理这个就好了。微软IME似乎也没有被这个绊倒。但是,如果我自己创建了一个模仿这种失去并重新获得焦点的应用程序(我也有一个有效的ITextStoreACP实现),那么只要我通过调用ITfThreadMgr :: AssociateFocus(hwnd)失去焦点,MS IME就会结束其
组成。 ,NULL,...)


我想了解为什么Excel会以这种方式运行,以及MS IME如何检测这种情况并且在这种情况下不会终止任何组合。

解决方案

您好,


感谢您在此发帖。


<你尝试使用
ITfThreadMgr :: SetFocus
方法而不是OnSetFocus方法。


当文档窗口收到输入时,应用程序必须调用此方法焦点。如果应用程序使用
将窗口与文档管理器相关联
ITfThreadMgr :: AssociateFocus
,TSF管理器为应用程序调用此方法。


最好的问候,


哈特



I am developing a Text Services Framework (TSF) based keyboard input method (Japanese for now). The ITfTextInputProcessorEx implementation installs a thread manager event sink (ITfThreadMgrEventSink) to listen for changes to which document manager has focus. If the focused document manager changes (or focus is lost) I want to terminate any unfinished composition. I noticed some interesting behaviour with typing into Microsoft Excel.

For example, if I select a cell, press 'k', then my IME will start a composition and insert a 'k'. However right after that I see that ITfThreadMgrEventSink::OnSetFocus is called two times: once with pdimFocus=NULL and pdimPrevFocus=<the doc mgr>, and a second time with pdimFocus=<the doc mgr> and pdimPrevFocus=NULL. So it loses the focus and immediately regains it. Then as long as the cell is in edit mode the focus is retained (so it is momentarily lost on first input into a cell).

I can confirm (via debugging) this also happens with the Microsoft IME and Google Japanese Input. However, Google Japanese Input generally seems to ignore OnSetFocus(NULL, ...) for anything other than updating its UI (its source code is open, so that was easy to confirm), so it handles this just fine. Microsoft IME also seems to not be tripped up by this. However, if I make an application myself which mimics this lose-and-regain focus (I have a working ITextStoreACP implementation too) then MS IME ends its composition as soon as I lose focus by calling ITfThreadMgr::AssociateFocus(hwnd, NULL, ...)

I'd like to understand why Excel behaves this way, and what MS IME does to detect this situation and not terminate any compositions in that case.

解决方案

Hi,

Thank you for posting here.

Did you try to use the ITfThreadMgr::SetFocus method instead of OnSetFocus method.

The application must call this method when the document window receives the input focus. If the application associates a window with a document manager using ITfThreadMgr::AssociateFocus, the TSF manager calls this method for the application.

Best Regards,

Hart


这篇关于帮助理解TSF和Excel焦点行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆