sycamore-rs / sycamore

A library for creating reactive web apps in Rust and WebAssembly
https://sycamore-rs.netlify.app
MIT License
2.79k stars 148 forks source link

Is there a case of a right-click pop-up menu? #652

Closed ys2rice2yangsong closed 8 months ago

ys2rice2yangsong commented 9 months ago

Is there a case of a right-click pop-up menu?

ys2rice2yangsong commented 9 months ago

use web_sys::{ Event, MouseEvent, wasm_bindgen::JsCast};

let contextmenu = move |e: Event| { e.prevent_default();

    let event = e.value_of()
        .dyn_into::<MouseEvent>().unwrap();
    let x = event.client_x();
    let y = event.client_y();                       
    console!(format!("鼠标位置:x==={},y==={}",x,y));

};
lukechu10 commented 8 months ago

I'm not sure what the question is here. Is it about creating a custom context menu in sycamore instead of the default browser one? It should be exactly the same as it is done in JS except using web-sys so I'm going to close this issue for now since it is not really related to Sycamore per se.