tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[feat] Add native context menu

Open axelthat opened this issue 2 years ago • 23 comments

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 avatar Jun 14 '22 14:06 axelthat

Electron already supports this.

Can you provide a link for their API?

amrbashir avatar Jun 14 '22 14:06 amrbashir

@amrbashir https://www.electronjs.org/docs/latest/api/menu#menupopupoptions

axelthat avatar Jun 14 '22 15:06 axelthat

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.

amrbashir avatar Jun 14 '22 15:06 amrbashir

Gotcha, thanks!

axelthat avatar Jun 14 '22 15:06 axelthat

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

martpie avatar Jul 26 '22 12:07 martpie

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

KaKi87 avatar Aug 06 '22 10:08 KaKi87

@KaKi87 Window menus are already possible

vdvman1 avatar Aug 06 '22 11:08 vdvman1

Isn't this issue about the JavaScript API ?

KaKi87 avatar Aug 06 '22 11:08 KaKi87

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

vdvman1 avatar Aug 06 '22 11:08 vdvman1

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

KaKi87 avatar Aug 06 '22 11:08 KaKi87

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

vdvman1 avatar Aug 06 '22 11:08 vdvman1

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

KaKi87 avatar Aug 06 '22 11:08 KaKi87

+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

Blatman avatar Sep 24 '22 21:09 Blatman

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

Dot32Dev avatar Jan 05 '23 02:01 Dot32Dev

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

dukeeagle avatar Apr 02 '23 20:04 dukeeagle

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.

martpie avatar May 26 '23 13:05 martpie

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.

FabianLars avatar May 26 '23 16:05 FabianLars

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 😊

goenning avatar May 27 '23 16:05 goenning

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

amrbashir avatar May 27 '23 20:05 amrbashir

@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?

goenning avatar May 27 '23 21:05 goenning

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

amrbashir avatar May 27 '23 21:05 amrbashir

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!

JonathanWilbur avatar May 29 '23 12:05 JonathanWilbur

  • https://github.com/bountysource/core/issues/1586

ghost avatar May 31 '23 06:05 ghost

First pay me something, then i do the bounty. It will take some time since im not avid with Rust. Oh i was not knowing about bountysource problem, so yeah, payme at least 35% and the rest when i finish. Are you just downvote and not say why?

AgCaliva avatar Jul 03 '23 17:07 AgCaliva

@AgCaliva , an admin/maintainer could ask for such terms, not a random developer.

If you have to ask "Why?" now, then you should gain experience first.

(btw: @bountysource has still not payed out, get your money back via paypal if you have funded a bounty)

ghost avatar Jul 03 '23 17:07 ghost

@abebeos no, i dont asked nothing, you downvoted without giving reasons. OK SEYA

AgCaliva avatar Jul 03 '23 17:07 AgCaliva

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

c2r0b avatar Jul 30 '23 21:07 c2r0b

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.

amrbashir avatar Jul 30 '23 23:07 amrbashir

@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?

martpie avatar Aug 14 '23 17:08 martpie

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

lucasfernog avatar Aug 14 '23 18:08 lucasfernog