macOS: add a way to hook standard keybinding events
Add macOS specific application handler to deliver macOS specific events. Co-authored-by: Mads Marquart <mads@marquart.dk>
This commit is contained in:
parent
a5f5ce6a3d
commit
c913cdab0b
5 changed files with 110 additions and 3 deletions
|
|
@ -22,7 +22,9 @@ use winit::event::{DeviceEvent, DeviceId, Ime, MouseButton, MouseScrollDelta, Wi
|
|||
use winit::event_loop::{ActiveEventLoop, EventLoop};
|
||||
use winit::keyboard::{Key, ModifiersState};
|
||||
#[cfg(macos_platform)]
|
||||
use winit::platform::macos::{OptionAsAlt, WindowAttributesExtMacOS, WindowExtMacOS};
|
||||
use winit::platform::macos::{
|
||||
ApplicationHandlerExtMacOS, OptionAsAlt, WindowAttributesExtMacOS, WindowExtMacOS,
|
||||
};
|
||||
#[cfg(any(x11_platform, wayland_platform))]
|
||||
use winit::platform::startup_notify::{
|
||||
self, EventLoopExtStartupNotify, WindowAttributesExtStartupNotify, WindowExtStartupNotify,
|
||||
|
|
@ -552,6 +554,23 @@ impl ApplicationHandler for Application {
|
|||
// We must drop the context here.
|
||||
self.context = None;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn macos_handler(&mut self) -> Option<&mut dyn ApplicationHandlerExtMacOS> {
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
impl ApplicationHandlerExtMacOS for Application {
|
||||
fn standard_key_binding(
|
||||
&mut self,
|
||||
_event_loop: &dyn ActiveEventLoop,
|
||||
window_id: WindowId,
|
||||
action: &str,
|
||||
) {
|
||||
info!(?window_id, ?action, "macOS standard key binding");
|
||||
}
|
||||
}
|
||||
|
||||
/// State of the window.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue