winit_core/application/macos.rs
1use crate::application::ApplicationHandler;
2use crate::event_loop::ActiveEventLoop;
3use crate::window::WindowId;
4
5/// Additional events on [`ApplicationHandler`] that are specific to macOS.
6///
7/// This can be registered with [`ApplicationHandler::macos_handler`].
8pub trait ApplicationHandlerExtMacOS: ApplicationHandler {
9 /// The system interpreted a keypress as a standard key binding command.
10 ///
11 /// Examples include inserting tabs and newlines, or moving the insertion point, see
12 /// [`NSStandardKeyBindingResponding`] for the full list of key bindings. They are often text
13 /// editing related.
14 ///
15 /// This corresponds to the [`doCommandBySelector:`] method on `NSTextInputClient`.
16 ///
17 /// The `action` parameter contains the string representation of the selector. Examples include
18 /// `"insertBacktab:"`, `"indent:"` and `"noop:"`.
19 ///
20 /// # Example
21 ///
22 /// ```ignore
23 /// impl ApplicationHandlerExtMacOS for App {
24 /// fn standard_key_binding(
25 /// &mut self,
26 /// event_loop: &dyn ActiveEventLoop,
27 /// window_id: WindowId,
28 /// action: &str,
29 /// ) {
30 /// match action {
31 /// "moveBackward:" => self.cursor.position -= 1,
32 /// "moveForward:" => self.cursor.position += 1,
33 /// _ => {} // Ignore other actions
34 /// }
35 /// }
36 /// }
37 /// ```
38 ///
39 /// [`NSStandardKeyBindingResponding`]: https://developer.apple.com/documentation/appkit/nsstandardkeybindingresponding?language=objc
40 /// [`doCommandBySelector:`]: https://developer.apple.com/documentation/appkit/nstextinputclient/1438256-docommandbyselector?language=objc
41 #[doc(alias = "doCommandBySelector:")]
42 fn standard_key_binding(
43 &mut self,
44 event_loop: &dyn ActiveEventLoop,
45 window_id: WindowId,
46 action: &str,
47 ) {
48 let _ = event_loop;
49 let _ = window_id;
50 let _ = action;
51 }
52}