webview icon indicating copy to clipboard operation
webview copied to clipboard

feat: menu items on Mac (maybe also other OSs?)

Open Bellisario opened this issue 2 years ago • 4 comments

Currently on Mac you need to click the close button to quit.
Would be useful to allow the usage of "standard" macOS shortcut for app actions (ex. CMD+Q, CMD+W, CMD+H, CMD+M, etc.).

Also, custom menu items support as Electron or Tauri would be fantastic.
Anyway, I tried looking in the Tauri source code but I was not able to understand the code (I'm not a Rust DEV), but I found the implementation should be here: https://github.com/tauri-apps/tauri/blob/dev/core/tauri-runtime/src/menu.rs

Bellisario avatar Aug 11 '23 13:08 Bellisario

Hey @Bellisario,

Thanks for reaching out. The problem with mac seems to be kown upstream with webview and macOS https://github.com/webview/webview/issues/397, https://github.com/webview/webview/issues/237

I'll look into it and think about a solution that is fitting for this binding.

As a quick-fix solution to implement shortcuts for now - though without a menu: You could implement shortcuts in JS. E.g. a cmd+q shortcut could call a V function to exit the application.

ttytm avatar Aug 11 '23 16:08 ttytm

Currently on Mac you need to click the close button to quit. Would be useful to allow the usage of "standard" macOS shortcut for app actions (ex. CMD+Q, CMD+W, CMD+H, CMD+M, etc.).

Also, custom menu items support as Electron or Tauri would be fantastic. Anyway, I tried looking in the Tauri source code but I was not able to understand the code (I'm not a Rust DEV), but I found the implementation should be here: https://github.com/tauri-apps/tauri/blob/dev/core/tauri-runtime/src/menu.rs

In regards to the custom menu items, I am busy developing a custom one for V using C, currently its still very early on and only supports Windows, but I am hoping to add Linux soon after, but MacOS will be a bit challenging since, I don't own a Mac, so will need someone else who is willing to help with that.

Here is a basic example.

image

@ttytm I am hoping once I am done to allow me to create a simple example of using both webview and Vtray together.

Ouri028 avatar Sep 15 '23 22:09 Ouri028

Sounds awesome @Ouri028!

If both libs complement each other ofc. you can add an example.

For a mac tray someone added a nice example to the examples in the V repo a while ago, it might help with mac as well https://github.com/vlang/v/tree/master/examples/macos_tray

ttytm avatar Sep 16 '23 00:09 ttytm

Hey guys,

I have just added MacOS support for VTray.

I only tested it on macos ventura, since that's what I'm currently use.

image5

Ouri028 avatar Sep 30 '23 22:09 Ouri028