Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need IsVisible option to MenuBarItem or MenuFlyoutItem class #23772

Open
cotrasys opened this issue Jul 23, 2024 · 0 comments
Open

Need IsVisible option to MenuBarItem or MenuFlyoutItem class #23772

cotrasys opened this issue Jul 23, 2024 · 0 comments
Labels

Comments

@cotrasys
Copy link

Description

I really need the KeyPress event for Keyboard shortcuts. .NET MAUI has no keyboard events.
This function has been discussing for ever and ever, but still has nothing here.

Desktop platforms: Mouse and Keyboard classes or DependencyServices · Issue #3739

You can detection with Sharphook. But this library has only Global Hooks.
No matter what if the program is background or not, the keyboard event will be fired.

Would be a replacement, I decided to use KeyboardAccelerators from .NET 8 .
It makes keyboard shortcut with simple coding like this below.

    <ContentPage.MenuBarItems>
        <MenuBarItem>
            <MenuFlyoutItem Clicked="MenuFlyoutItem_Clicked" Text="">
                <MenuFlyoutItem.KeyboardAccelerators>
                    <KeyboardAccelerator Key="Enter" Modifiers="Ctrl" />
                </MenuFlyoutItem.KeyboardAccelerators>
            </MenuFlyoutItem>
        </MenuBarItem>
    </ContentPage.MenuBarItems>
...
        private void MenuFlyoutItem_Clicked(object sender, EventArgs e)
        {
           //  You can do something...
        }

But it has a weak point. It occupied a space even if Text is empty.
You'll see a blank space, you can click this and showing unnecessary menu.
image

So I want IsVisible option for ToolbarItem class.

Public API Changes

Add IsVisible option to MenuBarItem, this effects top level menu.
If you want to each sub menu, add IsVisible option to lIMenuFlyoutItem interface,

    <ContentPage.MenuBarItems>
        <MenuBarItem IsVisible="False">
            <MenuFlyoutItem Clicked="MenuFlyoutItem_Clicked" Text="" IsVisible="False" />
        </MenuBarItem>
    </ContentPage.MenuBarItems>

Intended Use-Case

This changes will make accessable to simply operation from Keyboard without unnecessary menu displaying.

  • To select each bar chart, you just press Left and Right key.
  • In Chat app, you can confirm and send the message like Ctrl+Enter, Alt+Enter...
@samhouts samhouts added the area-controls-menubar Desktop MenuBarItems label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants