musealpha / src-tauri /src /browser /context_menu.rs
asdf98's picture
Upload 112 files
3d7d9b5 verified
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())
}