使用向左和向右箭头键选择上一个/下一个菜单,而不是下一个/上一个菜单 [英] Getting the Left and Right arrow keys to select the previous/next menu instead of the next/previous menu

查看:140
本文介绍了使用向左和向右箭头键选择上一个/下一个菜单,而不是下一个/上一个菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在完整的应用程序中标出,但在一个简单的演示中可以完全重现:

Noticed in a full application, but fully reproducable in a simple demo:

我有一个MenuStrip,其中包含三个菜单,ABC.每个菜单都包含三个项目,A1/A2/.../C2/C3.

I've got a MenuStrip containing three menus, A, B, and C. Each of these menus contains three items, A1/A2/.../C2/C3.

当我按 Alt 时,第一个菜单A被选中.然后,我可以使用键选择其他菜单.那是应该的.

When I press Alt, the first menu A becomes selected. I can then use the and keys to select other menus. That is as it should be.

但是,当我按打开菜单时,我仍然可以使用选择其他菜单,但是顺序相反:选择下一个菜单,而则选择上一个菜单.

However, when I press to open a menu, I can still use and to select other menus, but the order is reversed: selects the next menu, and the previous.

我无法弄清楚本地系统是否有问题,这是MenuStrip组件中的错误还是忘记设置必需的属性.这三个对我来说似乎都很奇怪,因为在所有三种情况下,我都希望某人已经遇到了这个问题,而我什至找不到其他人在问这个问题.

I'm having trouble figuring out if something is wrong with my local system, if this is a bug in the MenuStrip component, or if I am forgetting to set a required property. All three seem strange to me, because in all three cases I would expect someone to have encountered this problem already, and I cannot even find anyone else asking about this.

如果不清楚我要问的是什么,这是一张图片:

If it's not clear what I'm asking, here is an image:

在我忘记提及之前,没有没有相关代码.该演示应用程序是一个全新的WinForms项目,在其默认窗体中添加了一个MenuStrip控件,并具有三个菜单,每个菜单包含三个项目,我为每个菜单都设置了文字.

And before I forget to mention, there is no relevant code. This demo application is a brand new WinForms project, has one MenuStrip control added to its default form, and has got three menus with three items each, for each of which I have set nothing more than the text.

推荐答案

这是MenuStrip中的错误/错误功能.

This is a bug/misfeature in MenuStrip.

使用Reflector查看ToolStripDropDown.ProcessArrowKey实现会显示箭头键取决于SystemInformation.RightAlignedMenus的方向相反.那是不对的. 应该取决于菜单栏本身的从右到左模式,有时(通常是?)可以匹配SystemInformation.RightAlignedMenus,但并不总是如此,而不是在我的系统上.

Looking at the ToolStripDropDown.ProcessArrowKey implementation with Reflector shows that the arrow keys get reversed depending on SystemInformation.RightAlignedMenus. That's not right. It should depend on the right-to-left mode of the menu strip itself, which may sometimes (usually?) match SystemInformation.RightAlignedMenus, but not always, and not on my system.

SystemInformation.RightAlignedMenus是用户可通过控制面板","Tablet PC设置",其他",惯用性"进行配置的,实际上,如果将其更改为惯用左手",则菜单将正常运行.我的默认正确设置是惯用右手.由于MenuStrip组件在系统上根本无法在键盘上使用,因此我将其替换为标准的MainMenu组件.

SystemInformation.RightAlignedMenus is user-configurable via Control Panel, Tablet PC Settings, Other, Handedness, and indeed if I change that to Left-handed, I get the menus to behave correctly. The default and correct setting for me is Right-handed. Since the MenuStrip component is simply not keyboard-usable on my system, I will replace my use of it with a standard MainMenu component.

更新:我实际上是在使用派生控件来提供漂亮的菜单图像.它基于视觉样式菜单"上的Microsoft示例.

Update: I'm actually using a derived control to be able to provide nice menu images. It is based on the Microsoft sample on "Visual Style Menus". A more fully-featured implementation that also works on Windows XP and prior (in that case using owner-drawn menus) is available at Vista Menu with Icons in C#, but that is more complicated than necessary for me.

这篇关于使用向左和向右箭头键选择上一个/下一个菜单,而不是下一个/上一个菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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