mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 13:37:09 +00:00
feat(tauri): impl App::set_device_event_filter for AppHandle also (#14008)
* feat(tauri): impl `App::set_device_event_filter` for `AppHandle` also * Update .changes/impl-set_device_event_filter-for-apphandle.md * Update .changes/impl-set_device_event_filter-for-apphandle.md --------- Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
This commit is contained in:
parent
b21d86a8a3
commit
22d6bcacbb
7
.changes/impl-set_device_event_filter-for-apphandle.md
Normal file
7
.changes/impl-set_device_event_filter-for-apphandle.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri-runtime-wry": minor:feat
|
||||
"tauri-runtime": minor:feat
|
||||
"tauri": minor:feat
|
||||
---
|
||||
|
||||
Implement `App::set_device_event_filter` for `AppHandle` also.
|
||||
@ -1434,6 +1434,7 @@ pub enum WebviewMessage {
|
||||
pub enum EventLoopWindowTargetMessage {
|
||||
CursorPosition(Sender<Result<PhysicalPosition<f64>>>),
|
||||
SetTheme(Option<Theme>),
|
||||
SetDeviceEventFilter(DeviceEventFilter),
|
||||
}
|
||||
|
||||
pub type CreateWindowClosure<T> =
|
||||
@ -2641,6 +2642,13 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
|
||||
)
|
||||
}
|
||||
|
||||
fn set_device_event_filter(&self, filter: DeviceEventFilter) {
|
||||
let _ = send_user_message(
|
||||
&self.context,
|
||||
Message::EventLoopWindowTarget(EventLoopWindowTargetMessage::SetDeviceEventFilter(filter)),
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn find_class<'a>(
|
||||
&self,
|
||||
@ -3901,6 +3909,9 @@ fn handle_user_message<T: UserEvent>(
|
||||
EventLoopWindowTargetMessage::SetTheme(theme) => {
|
||||
event_loop.set_theme(to_tao_theme(theme));
|
||||
}
|
||||
EventLoopWindowTargetMessage::SetDeviceEventFilter(filter) => {
|
||||
event_loop.set_device_event_filter(DeviceEventFilterWrapper::from(filter).0);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,6 +329,15 @@ pub trait RuntimeHandle<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'st
|
||||
#[cfg_attr(docsrs, doc(cfg(target_os = "macos")))]
|
||||
fn hide(&self) -> Result<()>;
|
||||
|
||||
/// Change the device event filter mode.
|
||||
///
|
||||
/// See [Runtime::set_device_event_filter] for details.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// See [Runtime::set_device_event_filter] for details.
|
||||
fn set_device_event_filter(&self, filter: DeviceEventFilter);
|
||||
|
||||
/// Finds an Android class in the project scope.
|
||||
#[cfg(target_os = "android")]
|
||||
fn find_class<'a>(
|
||||
|
||||
@ -623,6 +623,17 @@ impl<R: Runtime> AppHandle<R> {
|
||||
.set_dock_visibility(visible)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Change the device event filter mode.
|
||||
///
|
||||
/// See [App::set_device_event_filter] for details.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// See [App::set_device_event_filter] for details.
|
||||
pub fn set_device_event_filter(&self, filter: DeviceEventFilter) {
|
||||
self.runtime_handle.set_device_event_filter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: Runtime> Manager<R> for AppHandle<R> {
|
||||
|
||||
@ -270,6 +270,10 @@ impl<T: UserEvent> RuntimeHandle<T> for MockRuntimeHandle {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_device_event_filter(&self, _: DeviceEventFilter) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn find_class<'a>(
|
||||
&self,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user