简体   繁体   English

如何在NetBeans菜单栏中添加快捷键?

[英]How to add shortcut keys to netbeans menu bar?

I am developing a Netbeans RCP application, in this we needed a custom menu bar so i created a XML layer file, and in it i created a folder called Test in Menu bar folder.But unfortunately i do not know how to add shortcuts to it Eg: like Alt+f which opens the pop options of File menu. 我正在开发一个Netbeans RCP应用程序,在此我们需要一个自定义菜单栏,因此我创建了一个XML层文件,并在其中创建了一个名为Test in Menu bar的文件夹。但是不幸的是,我不知道如何在其中添加快捷方式例如:类似于Alt + f ,可打开“ 文件”菜单的弹出选项。 I am able to add actions and shortcuts to sub menus created under Test but i am unable to add shortcuts to the Test menu itself.I want the menu to open its pop up with Alt+B command.Could someone give many ideas on how to do this. 我可以在“ 测试”下创建的子菜单中添加操作和快捷方式,但是我无法在“ 测试”菜单本身中添加快捷方式。我希望菜单使用Alt + B命令打开其弹出窗口。做这个。

I was able to fix this by adding a Mnemonic key to the Menu "Test" by adding displayname attribute to the "Test" folder in layer.xml file 我可以通过在display.xml文件中的“ Test”文件夹中添加displayname属性,向菜单“ Test”中添加助记键来解决此问题。

<folder name= "Menu">
   <folder name="Test"> 
      <attr name="displayName" bundlevalue="com.test.MenuBar.Bundle#Menu/Test"/>
   </folder>
</folder>

and in the module's Bundle.properties I added 并在模块的Bundle.properties中添加了

Menu/Test=Te&st 菜单/测试=特&ST

Here the character after & will be taken as the Mnemonic key ie character "S" . 此处之后的字符将被用作助记键,即字符“ S” So if you invoke "Alt+S" the "Test" menu pop-up will be displayed 因此,如果您调用“ Alt + S” ,则将显示“测试”菜单弹出窗口

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

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