objc2_ui_kit/generated/
UIKey.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikey?language=objc)
11    #[unsafe(super(NSObject))]
12    #[thread_kind = MainThreadOnly]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct UIKey;
15);
16
17unsafe impl NSCoding for UIKey {}
18
19unsafe impl NSCopying for UIKey {}
20
21unsafe impl CopyingHelper for UIKey {
22    type Result = Self;
23}
24
25unsafe impl NSObjectProtocol for UIKey {}
26
27impl UIKey {
28    extern_methods!(
29        /// Returns: a string representing what would be inserted into a text field when this key is pressed.
30        ///
31        /// if a modifier key is held, this property will contain the modified characters according
32        /// the rules for that particular modifier key (i.e., if shift is held on a Latin keyboard, this will
33        /// contain capital letters).
34        #[unsafe(method(characters))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn characters(&self) -> Retained<NSString>;
37
38        /// Returns: a string representing which characters would be inserted into a text field when this key is
39        /// pressed, not taking any held modifiers into account.
40        ///
41        /// for Latin based languages, expect this to be always in lowercase (unmodified meaning not
42        /// taking shift key into account). If only a modifier key was pressed, this property will contain an empty string.
43        #[unsafe(method(charactersIgnoringModifiers))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn charactersIgnoringModifiers(&self) -> Retained<NSString>;
46
47        #[cfg(feature = "UICommand")]
48        /// Returns: a bitfield representing which modifier keys are currently being held in addition to this key.
49        #[unsafe(method(modifierFlags))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;
52
53        #[cfg(all(feature = "UIKeyConstants", feature = "objc2-core-foundation"))]
54        /// Returns: the raw HID usage code for the pressed key. See UIKeyConstants.h.
55        #[unsafe(method(keyCode))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn keyCode(&self) -> UIKeyboardHIDUsage;
58    );
59}
60
61/// Methods declared on superclass `NSObject`.
62impl UIKey {
63    extern_methods!(
64        #[unsafe(method(init))]
65        #[unsafe(method_family = init)]
66        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
67
68        #[unsafe(method(new))]
69        #[unsafe(method_family = new)]
70        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
71    );
72}