ICSharpCode.TextEditor - KeyDown 问题
我正在尝试为 ICSharpCode.TextEditor 创建自动完成功能。 但 fileTabs_KeyDown 无法识别 Enter/Backspace/Tab/...
我尝试将新的 KeyEventHandler 添加到活动编辑器,但这不会调用我的 KeyDown 函数。
也许我可以直接请求 Windows 消息,但我不知道如何执行此操作,因为每个人都只使用 e.KeyDown 或 e.KeyPress 事件。
请帮忙...
I'm trying to create an auto-complete function for the ICSharpCode.TextEditor.
But the fileTabs_KeyDown doesn't recognize Enter/Backspace/Tab/...
I tried to add a new KeyEventHandler to the active editor but that doesn't call my KeyDown function.
Maybe I can request the windows messages directly but I don't know how to do this because everyone is only using e.KeyDown or e.KeyPress events.
Please help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ICSharpCode.TextEditor 是一个复合控件。如果将事件处理程序附加到主文本编辑器,您将不会收到任何事件。您必须附加到 textEditor.ActiveTextAreaControl.TextArea 上的事件。
此外,文本编辑器本身已经在处理这些事件。要拦截按键操作,请使用特殊事件 textEditor.ActiveTextAreaControl.TextArea.KeyEventHandler。
ICSharpCode.TextEditor is a composite control. If you attach event handlers to the main text editor, you won't receive any events. You have to attach to the events on textEditor.ActiveTextAreaControl.TextArea instead.
Also, the text editor itself is already handling the events. To intercept key presses, use the special event textEditor.ActiveTextAreaControl.TextArea.KeyEventHandler.
当按下 Enter / Backspace / Tab 键时,KeyPress、KeyDown 和 KeyEventHandler 不会触发。
要捕获这些按键,您必须处理 KeyUp 事件。
然后您可以检查 KeyEventArgs.KeyCode 的值
The KeyPress, KeyDown and KeyEventHandler to not fire when hitting the Enter / Backspace / Tab Keys.
To trap these key presses, you must handle the KeyUp event.
You can then check the value of KeyEventArgs.KeyCode
正如 Daniel 所说,您使用“ActiveTextAreaControl.TextArea”事件来捕获 Enter、Space 和组合等键,您使用如下代码,其中我捕获了 CTRL + Space 组合:
在本例中,我什至检索了插入符,因为我想在那里显示一个弹出窗口。
As Daniel said you use the 'ActiveTextAreaControl.TextArea' events, to capture, keys like Enter, Space, and Combinations you use code like the following where im catching a CTRL + Space combination:
In this example im even retrieving the screen coordinates of the Caret, cuz I want to show a popup window there.