File size: 769 Bytes
3d7d9b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use serde::{Deserialize, Serialize};
use tauri::{AppHandle, Emitter};

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ContextMenuInfo {
    pub x: f64,
    pub y: f64,
    pub client_x: f64,
    pub client_y: f64,
    pub tag_name: Option<String>,
    pub src: Option<String>,
    pub href: Option<String>,
    pub text: Option<String>,
    pub page_url: Option<String>,
}

/// Called from the child WebView's contextmenu event handler.
/// Emits the context menu info to the React shell which renders its own menu.
#[tauri::command]
pub fn browser_context_menu(app: AppHandle, info: ContextMenuInfo) -> Result<(), String> {
    app.emit("browser://context-menu", info).map_err(|e| e.to_string())
}