objc2_app_kit/generated/
NSTextInputContext.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
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextinputsourceidentifier?language=objc)
11pub type NSTextInputSourceIdentifier = NSString;
12
13extern_class!(
14    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextinputcontext?language=objc)
15    #[unsafe(super(NSObject))]
16    #[thread_kind = MainThreadOnly]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct NSTextInputContext;
19);
20
21unsafe impl NSObjectProtocol for NSTextInputContext {}
22
23impl NSTextInputContext {
24    extern_methods!(
25        #[unsafe(method(currentInputContext))]
26        #[unsafe(method_family = none)]
27        pub unsafe fn currentInputContext(
28            mtm: MainThreadMarker,
29        ) -> Option<Retained<NSTextInputContext>>;
30
31        #[cfg(feature = "NSTextInputClient")]
32        #[unsafe(method(initWithClient:))]
33        #[unsafe(method_family = init)]
34        pub unsafe fn initWithClient(
35            this: Allocated<Self>,
36            client: &ProtocolObject<dyn NSTextInputClient>,
37        ) -> Retained<Self>;
38
39        #[unsafe(method(init))]
40        #[unsafe(method_family = init)]
41        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
42
43        #[cfg(feature = "NSTextInputClient")]
44        /// ** Properties ****
45        #[unsafe(method(client))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn client(&self) -> Retained<ProtocolObject<dyn NSTextInputClient>>;
48
49        #[unsafe(method(acceptsGlyphInfo))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn acceptsGlyphInfo(&self) -> bool;
52
53        /// Setter for [`acceptsGlyphInfo`][Self::acceptsGlyphInfo].
54        #[unsafe(method(setAcceptsGlyphInfo:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn setAcceptsGlyphInfo(&self, accepts_glyph_info: bool);
57
58        #[unsafe(method(allowedInputSourceLocales))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn allowedInputSourceLocales(&self) -> Option<Retained<NSArray<NSString>>>;
61
62        /// Setter for [`allowedInputSourceLocales`][Self::allowedInputSourceLocales].
63        #[unsafe(method(setAllowedInputSourceLocales:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn setAllowedInputSourceLocales(
66            &self,
67            allowed_input_source_locales: Option<&NSArray<NSString>>,
68        );
69
70        /// ** Activation ****
71        #[unsafe(method(activate))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn activate(&self);
74
75        #[unsafe(method(deactivate))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn deactivate(&self);
78
79        #[cfg(feature = "NSEvent")]
80        /// ** Input source interface ***
81        #[unsafe(method(handleEvent:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn handleEvent(&self, event: &NSEvent) -> bool;
84
85        #[unsafe(method(discardMarkedText))]
86        #[unsafe(method_family = none)]
87        pub fn discardMarkedText(&self);
88
89        #[unsafe(method(invalidateCharacterCoordinates))]
90        #[unsafe(method_family = none)]
91        pub fn invalidateCharacterCoordinates(&self);
92
93        #[unsafe(method(textInputClientWillStartScrollingOrZooming))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn textInputClientWillStartScrollingOrZooming(&self);
96
97        #[unsafe(method(textInputClientDidEndScrollingOrZooming))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn textInputClientDidEndScrollingOrZooming(&self);
100
101        /// ** Text Input sources handling ***
102        #[unsafe(method(keyboardInputSources))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn keyboardInputSources(
105            &self,
106        ) -> Option<Retained<NSArray<NSTextInputSourceIdentifier>>>;
107
108        #[unsafe(method(selectedKeyboardInputSource))]
109        #[unsafe(method_family = none)]
110        pub fn selectedKeyboardInputSource(&self) -> Option<Retained<NSTextInputSourceIdentifier>>;
111
112        /// Setter for [`selectedKeyboardInputSource`][Self::selectedKeyboardInputSource].
113        #[unsafe(method(setSelectedKeyboardInputSource:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setSelectedKeyboardInputSource(
116            &self,
117            selected_keyboard_input_source: Option<&NSTextInputSourceIdentifier>,
118        );
119
120        /// ** Text Input source attributes ***
121        #[unsafe(method(localizedNameForInputSource:))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn localizedNameForInputSource(
124            input_source_identifier: &NSTextInputSourceIdentifier,
125            mtm: MainThreadMarker,
126        ) -> Option<Retained<NSString>>;
127    );
128}
129
130/// Methods declared on superclass `NSObject`.
131impl NSTextInputContext {
132    extern_methods!(
133        #[unsafe(method(new))]
134        #[unsafe(method_family = new)]
135        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
136    );
137}
138
139extern "C" {
140    /// ** Notifications ***
141    ///
142    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextinputcontextkeyboardselectiondidchangenotification?language=objc)
143    pub static NSTextInputContextKeyboardSelectionDidChangeNotification:
144        &'static NSNotificationName;
145}