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
20unsafe impl NSObjectProtocol for UIFocusSystem {}
21
22impl UIFocusSystem {
23    extern_methods!(
24        #[cfg(feature = "UIFocus")]
25        /// The currently focused item in this focus system.
26        #[unsafe(method(focusedItem))]
27        #[unsafe(method_family = none)]
28        pub unsafe fn focusedItem(&self) -> Option<Retained<ProtocolObject<dyn UIFocusItem>>>;
29
30        #[unsafe(method(new))]
31        #[unsafe(method_family = new)]
32        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
33
34        #[unsafe(method(init))]
35        #[unsafe(method_family = init)]
36        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
37
38        #[cfg(feature = "UIFocus")]
39        #[unsafe(method(focusSystemForEnvironment:))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn focusSystemForEnvironment(
42            environment: &ProtocolObject<dyn UIFocusEnvironment>,
43        ) -> Option<Retained<UIFocusSystem>>;
44
45        #[cfg(feature = "UIFocus")]
46        /// Requests a focus update to the specified environment. If accepted, the focus update will happen
47        /// in the next run loop cycle.
48        #[unsafe(method(requestFocusUpdateToEnvironment:))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn requestFocusUpdateToEnvironment(
51            &self,
52            environment: &ProtocolObject<dyn UIFocusEnvironment>,
53        );
54
55        /// Forces any pending focus update to be committed immediately.
56        #[unsafe(method(updateFocusIfNeeded))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn updateFocusIfNeeded(&self);
59
60        #[cfg(feature = "UIFocus")]
61        /// Returns true if `environment` is an ancestor of `otherEnvironment`, or false if otherwise.
62        #[unsafe(method(environment:containsEnvironment:))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn environment_containsEnvironment(
65            environment: &ProtocolObject<dyn UIFocusEnvironment>,
66            other_environment: &ProtocolObject<dyn UIFocusEnvironment>,
67        ) -> bool;
68    );
69}
70
71/// Sound.
72impl UIFocusSystem {
73    extern_methods!(
74        #[cfg(feature = "UIFocus")]
75        /// Registers a sound file for a given identifier.
76        #[unsafe(method(registerURL:forSoundIdentifier:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn registerURL_forSoundIdentifier(
79            sound_file_url: &NSURL,
80            identifier: &UIFocusSoundIdentifier,
81            mtm: MainThreadMarker,
82        );
83    );
84}
85
86/// UIFocusSystem.
87#[cfg(all(
88    feature = "UIResponder",
89    feature = "UIScene",
90    feature = "UIWindowScene"
91))]
92impl UIWindowScene {
93    extern_methods!(
94        /// Returns the focus system that is responsible for this scene or nil if this scene does not support focus.
95        #[unsafe(method(focusSystem))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn focusSystem(&self) -> Option<Retained<UIFocusSystem>>;
98    );
99}