I'm trying to migrate my app to V2 and Global Shortcut plugin makes it way too hard.
Here is my current code after migration:
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::{Manager};
use tauri_plugin_global_shortcut::GlobalShortcutExt;
#[allow(unused_must_use)]
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
.setup(|app| {
let window = app.get_window("main").unwrap();
app.global_shortcut().register("CommandOrControl+F11", move || {
let is_fullscreen = !window.is_fullscreen().unwrap_or(false);
window.set_fullscreen(is_fullscreen);
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Example from documentation does not work at all.
https://beta.tauri.app/guides/upgrade-migrate/from-tauri-1/#migrate-to-global-shortcut-plugin
This part from docs throws error:
.plugin(tauri_plugin_shortcut::init())
Moreover, tauri_plugin_shortcut doesn't even exist since it's called tauri_plugin_global_shortcut. And even then, ::init() doesn't work.
| .plugin(tauri_plugin_global_shortcut::init())
| ^^^^ not found in `tauri_plugin_global_shortcut`
After searching on Discord I found a way that doesn't throw error (see my code above) but I still can't make it work because it says it accepts only one argument. But then, how I'm supposed to attach a function to the shortcut?