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

[feat] Add native context menu #4338

Closed
axelthat opened this issue Jun 14, 2022 · 32 comments · Fixed by #7535
Closed

[feat] Add native context menu #4338

axelthat opened this issue Jun 14, 2022 · 32 comments · Fixed by #7535
Labels
status: backlog Issue is ready and we can work on it type: breaking change This issue or pull request will introduce a breaking change and requires major version bump type: feature request

Comments

@axelthat
Copy link

axelthat commented Jun 14, 2022

Describe the problem

Native context menu is missing.

Describe the solution you'd like

It would be cool to have native context menu. Electron already supports this.
Screen Shot 2022-06-14 at 7 44 30 PM

Alternatives considered

No response

Additional context

No response

@axelthat axelthat changed the title [feat] [feat] Add native context menu Jun 14, 2022
@amrbashir
Copy link
Member

Electron already supports this.

Can you provide a link for their API?

@axelthat
Copy link
Author

@amrbashir
Copy link
Member

amrbashir commented Jun 14, 2022

Thank you, this API won't ship into tauri v1 and will have to wait for v2 and will need to be implemented upstream first, in muda.

@axelthat
Copy link
Author

Gotcha, thanks!

@martpie
Copy link

martpie commented Jul 26, 2022

Some discord discussion about context menu (a feature I'm much looking forward to use in Tauri, as it is currently a hard-blocker for my project).

Yeah it’s a feature we’re aware of, but no one had the bandwidth to work on yet. It’s also by no means a trivial feature

https://discord.com/channels/616186924390023171/731495047962558564/981896781317144648

Advantages of a context menu:

  • looks native
  • easy sub-menus
  • can overflow out of the window
  • not having to care about accessibility
  • keyboard navigation out of the box
  • etc

@KaKi87
Copy link

KaKi87 commented Aug 6, 2022

Hello,
I would like to expand this feature request to the window menu bar as well.
Thanks

@vdvman1
Copy link

vdvman1 commented Aug 6, 2022

@KaKi87 Window menus are already possible

@KaKi87
Copy link

KaKi87 commented Aug 6, 2022

Isn't this issue about the JavaScript API ?

@vdvman1
Copy link

vdvman1 commented Aug 6, 2022

No, it's about being able to control the native right click context menu, right now the only option is to prevent the default context menu from showing and show a custom HTML menu

@KaKi87
Copy link

KaKi87 commented Aug 6, 2022

Yes, but I thought this issue would be about being able to do it from the JS API (@tauri-apps/api).

@vdvman1
Copy link

vdvman1 commented Aug 6, 2022

The issue doesn't even mention JS
Right now there is no API in JS or in Rust to modify the native context menu

@KaKi87
Copy link

KaKi87 commented Aug 6, 2022

The issue mention an Electron API which is a JS one, which is why I thought what I thought. Nevermind, I'll create separate issues if necessary

@Blatman
Copy link

Blatman commented Sep 24, 2022

+1 for native context menus which would probably be a variation of the window menus already implemented.

In the meantime I'm going to try and use a JS setup which may/may not work. Main issue is getting the accelerator keys going correctly (some work on Safari but not sure about the Tauri webview at this stage) but we'll see ....

https://github.com/Blatman/Custom-Context-Menu

@Dot32IsCool
Copy link

What needs to be implemented in muda? It already has custom context menu capabilities.

@amrbashir amrbashir added status: upstream status: backlog Issue is ready and we can work on it type: breaking change This issue or pull request will introduce a breaking change and requires major version bump and removed status: upstream labels Jan 5, 2023
@dukeeagle
Copy link

Bumping this! What's the current status of this?

@martpie
Copy link

martpie commented May 26, 2023

As the main blocker (muda) seems to be solved, I guess the main issue now is to come up with an API (Rust + JS?) for native menus.

Is it something we can expect for Tauri 2.0? I am not asking to get an exact deadline and I understand the amount of work the team has, but having some sense of roughly when we can expect this would be very helpful.

@FabianLars
Copy link
Sponsor Member

Very likely not for 2.0, no. We try to keep its scope reasonable small. Also i'm not sure how exactly it will work but i'd imagine it will be implemented as a plugin without many core changes so it may not even have to be coupled with a 2.X minor release.

@goenning
Copy link
Contributor

I love the idea of this feature being a plugin, big +1 from me.

I'll play with muda on my Tauri app and share my progress here! If anyone else is doing the same, please share some gists 😊

@amrbashir
Copy link
Member

muda will need to be added in tauri core not as a plugin, as it requires a bit more setup.

@goenning
Copy link
Contributor

@amrbashir can I use it currently on 1.3 if I add it myself as a dependency or does it need something into Tauri core before I can use it?

@amrbashir
Copy link
Member

Well, you probably can, but accelerators won't work on Windows (but it is already broken in tauri because of a webview2 bug)

@JonathanWilbur
Copy link

JonathanWilbur commented May 29, 2023

I really want this feature. Enough to have put out a $1500 bounty for its completion, in fact! (Full disclosure: I think BountySource takes a cut from the bounty hunter of 10%, so I think you'd walk away with $1350.) I have paid out a previous bounty of a similar amount, so I have a reputable history.

I will pay out when there is a merged PR for native context menus that fulfills the following acceptance criteria:

  1. Submenus
  2. Keyboard navigation
  3. Hotkey bindings
  4. Hotkey hints (see the screenshot in the original post: the grey text to the right of each option indicating the hotkey)
  5. Overflowing outside of the application's windows
  6. A sensible and safe API
  7. Anything else you'd expect from a native context menu (disappears when you click away, disappear when you press ESC (maybe), etc.)

If you are not an admin of this project, be warned that admins may elect not to accept your PR, in which case, this reward will not be paid out.

https://app.bountysource.com/issues/122317270-feat-add-native-context-menu

Good luck!

@ghost
Copy link

ghost commented May 31, 2023

@AgCaliva

This comment was marked as off-topic.

@ghost

This comment was marked as off-topic.

@AgCaliva

This comment was marked as off-topic.

@c2r0b
Copy link

c2r0b commented Jul 30, 2023

I am working on a plugin for this (currently supports MacOS only): https://github.com/c2r0b/tauri-plugin-context-menu
screenshot

Edit (2023-12-08): it now supports Windows, MacOS and Linux

@amrbashir
Copy link
Member

We are aware that this feature is long overdue and we have been working on it for a while now, it is almost done and should be in the next 2.0.0-alpha release.

As this requires multiple breaking changes in our stack, it will only be targeted for v2 and won't be backported to v1 as it will require tremendous effort that we would rather spend some where else.

Now we don't want to discourage anyone from tackling this issue for v1, it is definitely possible as a plugin.

@martpie
Copy link

martpie commented Aug 14, 2023

@amrbashir Big Kudos to the Tauri team for this. It seems the 2.0 alpha JS documentation is not complete, do you know if there is / will be some helpers to create context menus from the renderer process? Or is it a main process feature only that needs to be accessed via IPC?

@lucasfernog
Copy link
Member

@martpie for now we only have the Rust API implemented, but soon we'll publish the JS API.

@Sahasrara
Copy link

Sahasrara commented Dec 8, 2023

Is there a JS/TS API still a work in progress? Any ETA (even ballpark quarter)?

@Sahasrara
Copy link

@martpie for now we only have the Rust API implemented, but soon we'll publish the JS API.

Sorry, I just saw this! Is there a separate ticket for the JS/TS api?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backlog Issue is ready and we can work on it type: breaking change This issue or pull request will introduce a breaking change and requires major version bump type: feature request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.