简体   繁体   English

带有键盘快捷键的菜单

[英]Menu with keyboard shortcuts

I am developing application on Windows Mobile 6 (uses compact framework). 我正在Windows Mobile 6上开发应用程序(使用紧凑框架)。 The application uses a barcode scanner. 该应用程序使用条形码扫描仪。 I want to implement keyboard shortcuts in the menu. 我想在菜单中实现键盘快捷键。 I have implemented a keypress event in the menu so that if the user presses 1 the first menu item is opened and so on. 我已经在菜单中实现了一个按键事件,因此,如果用户按下1,则打开第一个菜单项,依此类推。 But my problem is that if the user scans the barcode with the device while the application is in the menu, the application gets the barcode read by the scanner and translates it to keypresses. 但是我的问题是,如果用户在菜单中使用应用程序扫描设备的条形码,则应用程序将获取扫描仪读取的条形码并将其转换为按键。 As I have keyboard shortcuts implemented in submenus as well, this means that if the user scans the barcode in the menu the application moves between menus. 由于我也在子菜单中实现了键盘快捷键,因此这意味着,如果用户扫描菜单中的条形码,则应用程序将在菜单之间移动。

I am not 100% sure but it seems that devices I use have barcode readers as "keyboard wedge" and when they are that kind you get text from them as if the user was typing it from the keyboard. 我不确定100%,但是似乎我使用的设备都具有条形码读取器作为“键盘楔”,当它们是那种类型时,您会从中获得文本,就像用户从键盘上键入文本一样。

This is how keypresses in the menu are implemented: 菜单中按键的实现方式如下:

private void mainList_KeyPress(object sender, KeyPressEventArgs e)
    {
            switch (e.KeyChar)
            {
                case (char)Keys.D1:
                    productRequestBtn_Click(sender, e);
                    break;
                case (char)Keys.D2:
                    warehouseBtn_Click(sender, e);
                    break;
                case (char)Keys.D3:
                    inventoryBtn_Click(sender, e);
                    break;
                case (char)Keys.D4:
                    ordersBtn_Click(sender, e);
                    break;
                case (char)Keys.D5:
                    discountBtn_Click(sender, e);
                    break;
                case (char)Keys.D6:
                    intakeBtn_Click(sender, e);
                    break;
                case (char)Keys.F1:
                    Close();
                    break;
            }
    }

I have tried different ways to implement it but haven't managed to solve my problem. 我尝试了不同的方法来实现它,但是没有设法解决我的问题。

If someone has any idea how to either change keyboard shortcuts implemented in menus, block a barcode reader or anything that might work in the described case, I would really appreciate it. 如果有人对更改菜单中实现的键盘快捷键,阻止条形码阅读器或在上述情况下可能起作用的任何操作有任何想法,我将不胜感激。

Yep, using the barcode scanner sdk would be the best solution. 是的,使用条形码扫描仪sdk将是最好的解决方案。

If want to avoid to code that OEM specific stuff you may workaround your issue using the keyboard wedges pos- and/or pre-amble settings. 如果要避免对OEM特定内容进行编码,则可以使用键盘楔子和/或前同步码设置来解决问题。

Most if not all of the wedge implementations support adding a sequence before and after the scanned data, this may be called preamble and postanble. 大多数(如果不是全部)楔形实现都支持在扫描数据之前和之后添加序列,这可以称为前同步码和后兼容码。 Using this feature you can change your code and for example disregard and keypresses if they start with * and end with # for example. 使用此功能,您可以更改代码,例如,如果它们以*开头和以#结尾,则可以忽略和按键。 If so, just add * as preamble and # as postamble in the wedge setup of your device. 如果是这样,只需在设备的楔形设置中添加*作为前同步码并添加#作为后同步码即可。 Using this technique you have to remove the chars in your barcode input field before you go on and validate/process the barcode data. 使用此技术,您必须先删除条形码输入字段中的字符,然后再继续进行验证/处理条形码数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM