Skip to content

Support opening a custom context menu when right-clicking a draggable region of the app under Windows #24893

Closed

Description

@fabiospampinato

Problem Description

Under Windows regions of the app that have -webkit-app-region: drag applied to them come also with a special context menu that can't be overridden.

Proposed Solution

I think it might be best to not show that default context menu at all, as it makes it impossible to provide a custom one. Also for whatever reason that context menu under Windows doesn't even look like the regular ones, I think it would be better to be able to provide users with consistent context menus.

Alternatives Considered

Reimplementing -webkit-app-region: drag? That'd be a bit crazy, if it's even possible to do at the app level.

Additional Information

Video showcasing the problem: https://i.imgur.com/FTGdWw0.mp4

Activity

  1. zcbenz commented on Aug 17, 2020

    @zcbenz
    Contributor

    Technically draggable regions work on Windows by marking the area as titlebar, so in theory we can support custom menu by support setting menu for titlebar. I don't think anyone in the team would be interested in implementing this, but I'm leaving this issue open.

  2. Kenhuey commented on Oct 18, 2020

    @Kenhuey

    I think this is a great enhancement, sometimes we need to drag window, but cannot disable the right-click menu. I am sad :(

  3. samuelmaddock commented on Jan 27, 2021

    @samuelmaddock
    Member

    It's now possible to prevent the system menu from appearing and display your own Menu in its place. This is thanks to the system-context-menu event added to the BrowserWindow in #25795

  4. fabiospampinato commented on Jan 27, 2021

    @fabiospampinato
    ContributorAuthor

    @samuelmaddock is that working for you? Last time I tried it wasn't working for me 🤔

  5. samuelmaddock commented on Jan 28, 2021

    @samuelmaddock
    Member

    @samuelmaddock is that working for you? Last time I tried it wasn't working for me 🤔

    Ah, looks like there's a known bug #26726. I was able to get the system-context-menu event to appear only when right-clicking on a framed window's title bar.

  6. qjl1569 commented on Apr 26, 2022

    @qjl1569

    // https://docs.microsoft.com/en-us/windows/win32/menurc/wm-initmenu?redirectedfrom=MSDN
    const WM_INITMENU = 0x0116;

    const menu = Menu.buildFromTemplate([
    {
    label: "Test",
    },
    {
    label: "Test",
    }
    ]);

    win.hookWindowMessage(WM_INITMENU, () => {
    win.setEnabled(false);
    win.setEnabled(true);

    menu.popup();
    });

    GIF

  7. whzard commented on Apr 27, 2022

    @whzard

    @qjl1569 your solution works, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions