ICSharpCode.TextEditor - KeyDown 问题

发布于 2024-08-03 22:41:59 字数 249 浏览 3 评论 0原文

我正在尝试为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦幻之岛 2024-08-10 22:41:59

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.

南七夏 2024-08-10 22:41:59

当按下 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

时光是把杀猪刀 2024-08-10 22:41:59

正如 Daniel 所说,您使用“ActiveTextAreaControl.TextArea”事件来捕获 Enter、Space 和组合等键,您使用如下代码,其中我捕获了 CTRL + Space 组合:

public frmConexon()
    {
        InitializeComponent();
        this.txtEditor.ActiveTextAreaControl.TextArea.KeyUp += new System.Windows.Forms.KeyEventHandler(TextArea_KeyUp);
    }

    void TextArea_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Space && e.Control)
        {
            TextArea S = (TextArea)sender;
            MessageBox.Show(string.Format("CTRL + Spacio ({0})", S.Caret.ScreenPosition.ToString()));
        }
    }

在本例中,我什至检索了插入符,因为我想在那里显示一个弹出窗口。

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:

public frmConexon()
    {
        InitializeComponent();
        this.txtEditor.ActiveTextAreaControl.TextArea.KeyUp += new System.Windows.Forms.KeyEventHandler(TextArea_KeyUp);
    }

    void TextArea_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Space && e.Control)
        {
            TextArea S = (TextArea)sender;
            MessageBox.Show(string.Format("CTRL + Spacio ({0})", S.Caret.ScreenPosition.ToString()));
        }
    }

In this example im even retrieving the screen coordinates of the Caret, cuz I want to show a popup window there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文