在KeyDown事件上检测星号键 [英] Detecting the Asterisk Key on KeyDown Event

查看:85
本文介绍了在KeyDown事件上检测星号键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我看到了以下答案 https://stackoverflow.com/a/7731051/626442 不足以满足我的需求.

Firstly I have seen the following answer https://stackoverflow.com/a/7731051/626442 and it is not quite sufficient for my needs.

我编写了具有基本智能感知功能的编辑器(请参阅 A新的和全面的通用Intellisense实现,以供深入研究.我已经使用此编辑器实现了一些基本的SQL Server完成,但是当我输入*键时,我会不断弹出智能提示.我想防止这种情况.目前,我正在执行以下操作:

I have written an editor which has basic intellisense capabilities (see A New and Full Implementation of Generic Intellisense for an insight). I have implemented some basic SQL Server completion using this editor, but I keep getting intellisense popping up when I type the * key. I want to prevent this. Currently I do the following:

private void TextArea_KeyDown(object sender, KeyEventArgs e)
{
    if (!e.Control && e.KeyCode == Keys.Space || e.Shift)
        return;

    IntellisenseEngine.DisplayCompletion(this, (char)e.KeyValue);
}

我最近重新开发了控件,我希望在现有限制上建立何时以及何时不显示洞察窗口的限制.我想要的子集是:

I have recently redeveloped my control and I want to build on existing restrictions as to when and when not to show the insight window. A subset of what I want would be:

+------------------------------+-------------------+
¦   ¦ Modifier   ¦ Keys        ¦ Show Completion   ¦
¦---+------------+-------------¦-------------------¦
¦ 1 ¦ Shift      ¦ None        ¦ No                ¦
¦ 2 ¦ Shift      ¦ * (see note)¦ No                ¦
¦ 3 ¦ None       ¦ Space       ¦ No                ¦
¦ 4 ¦ Any        ¦ Arrow Keys  ¦ No                ¦
+------------------------------+-------------------+

等注意,"*" e.KeyCodeD8,这显然不是键盘不变的,并且取决于语言环境,因此是不够的.

et al. Note, the "*" e.KeyCode is D8, this is obviously not keyboard invariant and dependent on locale, hence is not sufficient.

本质上,我希望我的SQL智能感知像SQL Server Management Studio(SQLMS)一样,我的问题是:

Essentially I want my SQL intellisense to act like SQL Server Management Studio's (SQLMS), my questions are:

  1. 我如何检测独立于键盘语言环境的星号char键.

  1. How can I detect the asterisk char key being pressed independent of keyboard locale.

我还应该施加哪些其他关键条件来抑制智能感知窗口的弹出并使其像SQLMS一样起作用?

What other key contions should I impose to make to suppress the pop-up of the intellisense window and to make it act like SQLMS?

我尝试使用

private void TextArea_KeyPress(object sender, KeyPressEventArgs e)
{
    if ((Control.ModifierKeys & Keys.Control) != Keys.Control && <Detect Space Bar> || 
         (Control.ModifierKeys & Keys.Shift) == Keys.Shift && e.KeyChar == '*')
    return;

    IntellisenseEngine.DisplayCompletion(this, (char)e.KeyValue);
}

但是后来我遇到了检测空格键的问题.

But then I have the problem of detecting the space bar.

感谢您的时间.

推荐答案

检查修改后的代码.希望它能工作

Check the modified code . Hope it will work

private void TextArea_KeyPress(object sender, KeyPressEventArgs e)
{
    if ((Control.ModifierKeys & Keys.Contro) != Keys.Control && e.KeyChar == ' ' || 
         (Control.ModifierKeys & Keys.Shift) == Keys.Shift && e.KeyChar == '*')
    return;

    IntellisenseEngine.DisplayCompletion(this, (char)e.KeyValue);
}

这篇关于在KeyDown事件上检测星号键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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