是否可以从键盘输入切换菜单?

时间:2022-08-22 12:15:43

I'm building a dashboard'ish application for a special purpose hardware that has physical buttons that are bound to F1-F10, Up, Down, Backspace, Enter. The application consists of a few views (implemented using the MVVM-pattern) and most of the user interaction are done with menus that are aligned near the physical buttons. I'm trying to toggle the menu state by pressing the F-keys but I just can't get the bloody thing to work!

我正在构建一个专用硬件的仪表板应用程序,它具有绑定到F1-F10,Up,Down,Backspace,Enter的物理按钮。该应用程序包含一些视图(使用MVVM模式实现),并且大多数用户交互都是通过在物理按钮附近对齐的菜单完成的。我正试图通过按F键切换菜单状态,但我无法让血腥的东西工作!

I've (successfully, kinda) tried an alternative solution that catches the F-keys and sends them as regular numbers 1-10 and mapping Alt+[1-10] to the meny using Accesskey. That is not an optimal solution though since I have to keep track of if the menu looses focus (the user can also navigate with a touch screen). Besides that I also have try and hide the accesskey-text from the menuitem-header (since it seems impossible to just make it invisible).

我(成功地,有点)尝试了一种替代解决方案,它捕获F键并将它们作为常规数字1-10发送,并使用Accesskey将Alt + [1-10]映射到meny。这不是最佳解决方案,因为我必须跟踪菜单是否失去焦点(用户还可以使用触摸屏导航)。除此之外,我还尝试隐藏menuitem-header中的accesskey-text(因为它似乎不可能让它看不见)。

1 个解决方案

#1


Honestly, I'd just make a regular Window and hide/show it as appropriate - just have an ItemsControl whose DataTemplate is a MenuItem. Menus are managed in the standard "menu" way, so it'll be hard to override it and manually manage the hidden/shown state.

老实说,我只是制作一个常规窗口并隐藏/显示它 - 只需要一个ItemsControl,其DataTemplate是一个MenuItem。菜单以标准“菜单”方式管理,因此很难覆盖菜单并手动管理隐藏/显示状态。

#1


Honestly, I'd just make a regular Window and hide/show it as appropriate - just have an ItemsControl whose DataTemplate is a MenuItem. Menus are managed in the standard "menu" way, so it'll be hard to override it and manually manage the hidden/shown state.

老实说,我只是制作一个常规窗口并隐藏/显示它 - 只需要一个ItemsControl,其DataTemplate是一个MenuItem。菜单以标准“菜单”方式管理,因此很难覆盖菜单并手动管理隐藏/显示状态。