c2r0b / tauri-plugin-context-menu Goto Github PK
View Code? Open in Web Editor NEWNative Context Menu in Tauri
Home Page: https://crates.io/crates/tauri-plugin-context-menu
License: MIT License
Native Context Menu in Tauri
Home Page: https://crates.io/crates/tauri-plugin-context-menu
License: MIT License
Hey ๐, excuse me. I'm using this plugin in EcoPaste, but I'm getting feedback that the context menu is unresponsive in Windows 10
, and partially in other communities as well! After some troubleshooting, this may not be an issue with EcoPaste
, as it is fine on both MacOS
and Windows 11
! Hope you guys can help me out with this, thanks ๐น!
Hi
This plugin works great, but my app requires different context menus when I right click in different areas. Is that possible to implement?
I have tried adding the event listener directly to the element, but custom context menus wouldn't show up :(
Updating crates.io index
error: failed to select a version for `tauri`.
... required by package `tauri-plugin-context-menu v0.5.0 (https://github.com/c2r0b/tauri-plugin-context-menu?branch=main#41d5cec1)`
... which satisfies git dependency `tauri-plugin-context-menu` of package `my-project v0.0.1 (C:\workspace\my-project\src-tauri)`
versions that meet the requirements `^1.5` are: 1.5.2, 1.5.1, 1.5.0
all possible versions conflict with previously selected packages.
previously selected package `tauri v1.4.1`
... which satisfies dependency `tauri = "^1.4"` (locked to 1.4.1) of package `my-project v0.0.1 (C:\workspace\my-project\src-tauri)`
Every time you call showMenu
a new listener for theevent
function will be created, previous ones are not removed currently, which results in the function being called multiple times.
There is nothing wrong with the JS events, everything is the expected behavior, this error doesn't happen every time, but it occurs quite frequently.
There is also a GTK warning, which I'm not sure is relevant:
No trigger event for menu popup
System: Fedora 39
Can you add a TypeScript API wrapper? Like https://github.com/CrossCopy/tauri-plugin-clipboard/blob/main/webview-src/index.ts
for example: cmd_or_ctrl
, backspace
here's more if you want more complete support: https://www.electronjs.org/docs/latest/api/accelerator
Great plugin !
Is there any plan to support metadata?
like:
{
label: 'My first subitem',
event: 'my_first_subitem',
metadata: '{"id":123}' // any string
}
Reproduction
export GDK_BACKEND=x11
npm run examples/vanilla
You will see that the context menu is not in the same position as the mouse
, it seems to be based on the position of the screen
.
If you use wayland
backend, you won't have this issue.
export GDK_BACKEND=wayland
npm run examples/vanilla
Note: AppImage
built on Tauri uses x11
as backend.
Hey, thanks for such a great plugin, I'm currently using tauri-plugin-theme for dynamic theme switching, is it possible to provide a theme
parameter to dynamically change the theme color of the menu?
I tried with the latest version 0.7.1
on macOS 14.2.1 (23C71) (Apple M1), but when tauriApi.invoke
was called, the app crashed and got the following error:
thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-plugin-context-menu-0.7.1/src/macos.rs:205:60:
Class should exist
stack backtrace:
0: rust_begin_unwind
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
2: core::panicking::panic_display
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:197:5
3: core::panicking::panic_str
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:172:5
4: core::option::expect_failed
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:1995:5
5: core::option::Option<T>::expect
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:896:21
6: tauri_plugin_context_menu::os::create_context_menu
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-plugin-context-menu-0.7.1/src/macos.rs:205:13
7: tauri_plugin_context_menu::os::show_context_menu::{{closure}}
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-plugin-context-menu-0.7.1/src/macos.rs:221:20
8: dispatch::context_and_function::work_execute_closure
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dispatch-0.2.0/src/lib.rs:94:9
9: <unknown>
10: <unknown>
11: <unknown>
12: <unknown>
13: <unknown>
14: <unknown>
15: <unknown>
16: <unknown>
17: <unknown>
18: <unknown>
19: <unknown>
20: <unknown>
21: <() as objc::message::MessageArguments>::invoke
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:128:17
22: objc::message::platform::send_unverified::{{closure}}
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/apple/mod.rs:27:9
23: objc_exception::try::{{closure}}
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:68:31
24: objc_exception::try_no_ret::try_objc_execute_closure
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:34:9
25: RustObjCExceptionTryCatch
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/extern/exception.m:10:9
26: objc_exception::try_no_ret
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:44:19
27: objc_exception::try
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc_exception-0.1.2/src/lib.rs:67:9
28: objc::exception::try
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/exception.rs:8:5
29: objc::message::platform::send_unverified
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/apple/mod.rs:26:5
30: objc::message::send_message
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:178:5
31: tao::platform_impl::platform::event_loop::EventLoop<T>::run_return
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/event_loop.rs:193:16
32: tao::platform_impl::platform::event_loop::EventLoop<T>::run
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/platform_impl/macos/event_loop.rs:160:21
33: tao::event_loop::EventLoop<T>::run
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.16.9/src/event_loop.rs:179:5
34: <tauri_runtime_wry::Wry<T> as tauri_runtime::Runtime<T>>::run
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-runtime-wry-0.14.8/src/lib.rs:2299:5
35: tauri::app::App<R>::run
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-1.6.7/src/app.rs:868:5
36: tauri::app::Builder<R>::run
at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-1.6.7/src/app.rs:1723:5
37: testapp_lib::run
at ./src/lib.rs:81:3
38: testapp_app::main
at ./src/main.rs:7:3
39: core::ops::function::FnOnce::call_once
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
libc++abi: terminating due to uncaught foreign exception
Any ideas?
Running github action to make a release
The windows
and the Mac
workflow build succeeded but the Linux
Ubuntu some how failed due to the error below
Compiling tauri-plugin-oauth v0.0.0 (https://github.com/FabianLars/tauri-plugin-oauth?branch=main#26e38115)
Compiling tauri-plugin-context-menu v0.5.0 (https://github.com/c2r0b/tauri-plugin-context-menu?branch=main#41d5cec1)
error[E0433]: failed to resolve: use of undeclared crate or module `os`
--> /home/runner/.cargo/git/checkouts/tauri-plugin-context-menu-2c3100763c3e1052/41d5cec/src/lib.rs:60:9
|
60 | os::show_context_menu(context_menu, window, pos, items);
| ^^ use of undeclared crate or module `os`
I use a second display connecting to my MacBook Pro. The context menu works fine in the main display (the MacBook one), but the menu position is outside of the app in the second display.
Any ideas?
The positioning issue still comes up on MacOS.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.