objc2_ui_kit/generated/
UIFocusSystem.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// UIFocusSystem instances manage focus state within a part of the user interface. They are in charge of tracking the current focused item, as well as processing focus updates.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uifocussystem?language=objc)
14    #[unsafe(super(NSObject))]
15    #[thread_kind = MainThreadOnly]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    pub struct UIFocusSystem;
18);
19
20extern_conformance!(
21    unsafe impl NSObjectProtocol for UIFocusSystem {}
22);
23
24impl UIFocusSystem {
25    extern_methods!(
26        #[cfg(feature = "UIFocus")]
27        /// The currently focused item in this focus system.
28        #[unsafe(method(focusedItem))]
29        #[unsafe(method_family = none)]
30        pub unsafe fn focusedItem(&self) -> Option<Retained<ProtocolObject<dyn UIFocusItem>>>;
31
32        #[unsafe(method(new))]
33        #[unsafe(method_family = new)]
34        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
35
36        #[unsafe(method(init))]
37        #[unsafe(method_family = init)]
38        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
39
40        #[cfg(feature = "UIFocus")]
41        #[unsafe(method(focusSystemForEnvironment:))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn focusSystemForEnvironment(
44            environment: &ProtocolObject<dyn UIFocusEnvironment>,
45        ) -> Option<Retained<UIFocusSystem>>;
46
47        #[cfg(feature = "UIFocus")]
48        /// Requests a focus update to the specified environment. If accepted, the focus update will happen
49        /// in the next run loop cycle.
50        #[unsafe(method(requestFocusUpdateToEnvironment:))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn requestFocusUpdateToEnvironment(
53            &self,
54            environment: &ProtocolObject<dyn UIFocusEnvironment>,
55        );
56
57        /// Forces any pending focus update to be committed immediately.
58        #[unsafe(method(updateFocusIfNeeded))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn updateFocusIfNeeded(&self);
61
62        #[cfg(feature = "UIFocus")]
63        /// Returns true if `environment` is an ancestor of `otherEnvironment`, or false if otherwise.
64        #[unsafe(method(environment:containsEnvironment:))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn environment_containsEnvironment(
67            environment: &ProtocolObject<dyn UIFocusEnvironment>,
68            other_environment: &ProtocolObject<dyn UIFocusEnvironment>,
69        ) -> bool;
70    );
71}
72
73/// Sound.
74impl UIFocusSystem {
75    extern_methods!(
76        #[cfg(feature = "UIFocus")]
77        /// Registers a sound file for a given identifier.
78        #[unsafe(method(registerURL:forSoundIdentifier:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn registerURL_forSoundIdentifier(
81            sound_file_url: &NSURL,
82            identifier: &UIFocusSoundIdentifier,
83            mtm: MainThreadMarker,
84        );
85    );
86}
87
88/// UIFocusSystem.
89#[cfg(all(
90    feature = "UIResponder",
91    feature = "UIScene",
92    feature = "UIWindowScene"
93))]
94impl UIWindowScene {
95    extern_methods!(
96        /// Returns the focus system that is responsible for this scene or nil if this scene does not support focus.
97        #[unsafe(method(focusSystem))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn focusSystem(&self) -> Option<Retained<UIFocusSystem>>;
100    );
101}