On Web, fix context menu not being disabled (#3282)
This commit is contained in:
parent
7761b2b16c
commit
4f669ebbd2
3 changed files with 19 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ Unreleased` header.
|
||||||
- On Windows, fix consecutive calls to `window.set_fullscreen(Some(Fullscreen::Borderless(None)))` resulting in losing previous window state when eventually exiting fullscreen using `window.set_fullscreen(None)`.
|
- On Windows, fix consecutive calls to `window.set_fullscreen(Some(Fullscreen::Borderless(None)))` resulting in losing previous window state when eventually exiting fullscreen using `window.set_fullscreen(None)`.
|
||||||
- On Wayland, fix resize being sent on focus change.
|
- On Wayland, fix resize being sent on focus change.
|
||||||
- On Windows, fix `set_ime_cursor_area`.
|
- On Windows, fix `set_ime_cursor_area`.
|
||||||
|
- On Web, fix context menu not being disabled by `with_prevent_default(true)`.
|
||||||
|
|
||||||
# 0.29.4
|
# 0.29.4
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -647,6 +647,8 @@ impl<T> EventLoopWindowTarget<T> {
|
||||||
|
|
||||||
let runner = self.runner.clone();
|
let runner = self.runner.clone();
|
||||||
canvas.on_animation_frame(move || runner.request_redraw(RootWindowId(id)));
|
canvas.on_animation_frame(move || runner.request_redraw(RootWindowId(id)));
|
||||||
|
|
||||||
|
canvas.on_context_menu(prevent_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn available_monitors(&self) -> VecDequeIter<MonitorHandle> {
|
pub fn available_monitors(&self) -> VecDequeIter<MonitorHandle> {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ use std::sync::{Arc, Mutex};
|
||||||
use smol_str::SmolStr;
|
use smol_str::SmolStr;
|
||||||
use wasm_bindgen::{closure::Closure, JsCast};
|
use wasm_bindgen::{closure::Closure, JsCast};
|
||||||
use web_sys::{
|
use web_sys::{
|
||||||
CssStyleDeclaration, Document, Event, FocusEvent, HtmlCanvasElement, KeyboardEvent, WheelEvent,
|
CssStyleDeclaration, Document, Event, FocusEvent, HtmlCanvasElement, KeyboardEvent,
|
||||||
|
PointerEvent, WheelEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
use crate::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||||
|
|
@ -41,6 +42,7 @@ pub struct Canvas {
|
||||||
on_intersect: Option<IntersectionObserverHandle>,
|
on_intersect: Option<IntersectionObserverHandle>,
|
||||||
animation_frame_handler: AnimationFrameHandler,
|
animation_frame_handler: AnimationFrameHandler,
|
||||||
on_touch_end: Option<EventListenerHandle<dyn FnMut(Event)>>,
|
on_touch_end: Option<EventListenerHandle<dyn FnMut(Event)>>,
|
||||||
|
on_context_menu: Option<EventListenerHandle<dyn FnMut(PointerEvent)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Common {
|
pub struct Common {
|
||||||
|
|
@ -150,6 +152,7 @@ impl Canvas {
|
||||||
on_intersect: None,
|
on_intersect: None,
|
||||||
animation_frame_handler: AnimationFrameHandler::new(window),
|
animation_frame_handler: AnimationFrameHandler::new(window),
|
||||||
on_touch_end: None,
|
on_touch_end: None,
|
||||||
|
on_context_menu: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -438,6 +441,17 @@ impl Canvas {
|
||||||
self.animation_frame_handler.on_animation_frame(f)
|
self.animation_frame_handler.on_animation_frame(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn on_context_menu(&mut self, prevent_default: bool) {
|
||||||
|
self.on_context_menu = Some(self.common.add_event(
|
||||||
|
"contextmenu",
|
||||||
|
move |event: PointerEvent| {
|
||||||
|
if prevent_default {
|
||||||
|
event.prevent_default();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn request_fullscreen(&self) {
|
pub fn request_fullscreen(&self) {
|
||||||
fullscreen::request_fullscreen(self.document(), self.raw());
|
fullscreen::request_fullscreen(self.document(), self.raw());
|
||||||
}
|
}
|
||||||
|
|
@ -511,6 +525,7 @@ impl Canvas {
|
||||||
self.on_intersect = None;
|
self.on_intersect = None;
|
||||||
self.animation_frame_handler.cancel();
|
self.animation_frame_handler.cancel();
|
||||||
self.on_touch_end = None;
|
self.on_touch_end = None;
|
||||||
|
self.on_context_menu = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue