Open akash07k opened 2 years ago
Use the AccessKey
property, like so:
<MenuBar>
<MenuBarItem Title="File" AccessKey="F">
<MenuFlyoutItem AccessKey="N" Text="New" />
<MenuFlyoutItem AccessKey="S" Text="Save" />
<MenuFlyoutItem AccessKey="X" Text="Exit" />
</MenuBarItem>
<MenuBarItem Title="Edit" AccessKey="E" />
</MenuBar
@BreeceW Thanks, but it will allow the user to open the menu with the keys such as "Alt+F" however, I want that as soon as as user presses alt, the menu bar should open. Like notepad does this.
Anyone please?
Update?
Can someone please provide any insights to fix this issue?
@castorix @ranjeshj Can you please help?
I am not sure I am following here. There is no provision for opening a menu on the pressing of "alt'. Alt is the key that transitions the application so that it expects access keys to follow (vs standard text characters). You then need to press a character key to get an action to occur.
In the case of the current releases of Notepad, when you press and release the alt button, keytips appear for the available menu items.
Pressing one of the defined access keys (F, E, V or S) will then open the corresponding menu (or the settings page in the case of S). This is the behavior you would get if you implemented BreeceW's suggestion above and is the designed behavior.
You can't use alt by itself as an accelerator because it isn't a character; it is a modifier. And if you could, you would end up disabling all the other access keys defined on the screen since they would require alt to be pressed BEFORE the access key itself is entered.
If you add the access keys suggested by BreeceW, then you will get the common menu bar behavior.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Not stale
This may be a focusing issue, Pressing Alt is intermittent in Paint.
Alt key can’t be used as an accelerator. The behavior you got is expected behavior.
Many other apps already do this. For example, modern Notepad.
Notepad doesn't do this. What modern Notepad does is the same as the AccessKey does.
No, I respectfully disagree 😊. Notepad doesn't do same as the AccessKey thingy. as soon as we press Alt in Notepad, it opens/invokes the Menu. I double checked it just now.
Alt key can’t be used as an accelerator. The behavior you got is expected behavior.
Many other apps already do this. For example, modern Notepad.
Notepad doesn't do this. What modern Notepad does is the same as the AccessKey does.
I also double checked it on my Windows 11 just now. Open the notepad app and press the Alt key. The notepad will show access key for menu items just like @ JJBrychell’s image. This is what I exactly get. Alt key will not open the MenuFlyout. If the MenuFlyout is opened already, it shows the access key for each item. This is the suggested solution from @BreeceW. Are you using the system built-in Notepad app?
In the case of the current releases of Notepad, when you press and release the alt button, keytips appear for the available menu items.
Pressing one of the defined access keys (F, E, V or S) will then open the corresponding menu (or the settings page in the case of S). This is the behavior you would get if you implemented BreeceW's suggestion above and is the designed behavior.
You can't use alt by itself as an accelerator because it isn't a character; it is a modifier. And if you could, you would end up disabling all the other access keys defined on the screen since they would require alt to be pressed BEFORE the access key itself is entered.
If you add the access keys suggested by BreeceW, then you will get the common menu bar behavior.
So I'm developing a WinUI3 app and Implementing a MenuBar inside it. I want to open the menu when user presses the "ALT" key. However, I'm unable to do so. There's no explicit way to accomplish this and by default it doesn't open via alt either. Many other apps already do this. For example, modern Notepad. And I think that it is developed in WinUI3. My code is like this:
Please help