objc2_web_kit/generated/
WKWebExtensionCommand.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::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern_class!(
14    /// A ``WKWebExtensionCommand`` object encapsulates the properties for an individual web extension command.
15    ///
16    /// Provides access to command properties such as a unique identifier, a descriptive title, and shortcut keys. Commands
17    /// can be used by a web extension to perform specific actions within a web extension context, such toggling features, or interacting with
18    /// web content. These commands enhance the functionality of the extension by allowing users to invoke actions quickly.
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncommand?language=objc)
21    #[unsafe(super(NSObject))]
22    #[thread_kind = MainThreadOnly]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct WKWebExtensionCommand;
25);
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for WKWebExtensionCommand {}
29);
30
31impl WKWebExtensionCommand {
32    extern_methods!(
33        #[unsafe(method(new))]
34        #[unsafe(method_family = new)]
35        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
36
37        #[unsafe(method(init))]
38        #[unsafe(method_family = init)]
39        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
40
41        #[cfg(feature = "WKWebExtensionContext")]
42        /// The web extension context associated with the command.
43        #[unsafe(method(webExtensionContext))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn webExtensionContext(&self) -> Option<Retained<WKWebExtensionContext>>;
46
47        /// A unique identifier for the command.
48        #[unsafe(method(identifier))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn identifier(&self) -> Retained<NSString>;
51
52        /// Descriptive title for the command aiding discoverability.
53        ///
54        /// This title can be displayed in user interface elements such as keyboard shortcuts lists or menu items to help users understand its purpose.
55        #[unsafe(method(title))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn title(&self) -> Retained<NSString>;
58
59        /// The primary key used to trigger the command, distinct from any modifier flags.
60        ///
61        /// This property can be customized within the app to avoid conflicts with existing shortcuts or to enable user personalization.
62        /// It should accurately represent the activation key as used by the app, which the extension can use to display the complete shortcut in its interface.
63        /// If no shortcut is desired for the command, the property should be set to `nil`. This value should be saved and restored as needed by the app.
64        #[unsafe(method(activationKey))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn activationKey(&self) -> Option<Retained<NSString>>;
67
68        /// Setter for [`activationKey`][Self::activationKey].
69        #[unsafe(method(setActivationKey:))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn setActivationKey(&self, activation_key: Option<&NSString>);
72
73        #[cfg(feature = "objc2-app-kit")]
74        #[cfg(target_os = "macos")]
75        #[unsafe(method(modifierFlags))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn modifierFlags(&self) -> NSEventModifierFlags;
78
79        #[cfg(feature = "objc2-app-kit")]
80        #[cfg(target_os = "macos")]
81        /// Setter for [`modifierFlags`][Self::modifierFlags].
82        #[unsafe(method(setModifierFlags:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn setModifierFlags(&self, modifier_flags: NSEventModifierFlags);
85
86        #[cfg(feature = "objc2-app-kit")]
87        #[cfg(target_os = "macos")]
88        #[unsafe(method(menuItem))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn menuItem(&self) -> Retained<NSMenuItem>;
91    );
92}