objc2_web_kit/generated/
WKNavigationAction.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::*;
5#[cfg(feature = "objc2-app-kit")]
6#[cfg(target_os = "macos")]
7use objc2_app_kit::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// The type of action triggering a navigation.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wknavigationtype?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct WKNavigationType(pub NSInteger);
19impl WKNavigationType {
20    #[doc(alias = "WKNavigationTypeLinkActivated")]
21    pub const LinkActivated: Self = Self(0);
22    #[doc(alias = "WKNavigationTypeFormSubmitted")]
23    pub const FormSubmitted: Self = Self(1);
24    #[doc(alias = "WKNavigationTypeBackForward")]
25    pub const BackForward: Self = Self(2);
26    #[doc(alias = "WKNavigationTypeReload")]
27    pub const Reload: Self = Self(3);
28    #[doc(alias = "WKNavigationTypeFormResubmitted")]
29    pub const FormResubmitted: Self = Self(4);
30    #[doc(alias = "WKNavigationTypeOther")]
31    pub const Other: Self = Self(-1);
32}
33
34unsafe impl Encode for WKNavigationType {
35    const ENCODING: Encoding = NSInteger::ENCODING;
36}
37
38unsafe impl RefEncode for WKNavigationType {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42extern_class!(
43    /// A WKNavigationAction object contains information about an action that may cause a navigation, used for making policy decisions.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wknavigationaction?language=objc)
46    #[unsafe(super(NSObject))]
47    #[thread_kind = MainThreadOnly]
48    #[derive(Debug, PartialEq, Eq, Hash)]
49    pub struct WKNavigationAction;
50);
51
52unsafe impl NSObjectProtocol for WKNavigationAction {}
53
54impl WKNavigationAction {
55    extern_methods!(
56        #[cfg(feature = "WKFrameInfo")]
57        /// The target frame, or nil if this is a new window navigation.
58        #[unsafe(method(targetFrame))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn targetFrame(&self) -> Option<Retained<WKFrameInfo>>;
61
62        /// The type of action that triggered the navigation.
63        ///
64        /// The value is one of the constants of the enumerated type WKNavigationType.
65        #[unsafe(method(navigationType))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn navigationType(&self) -> WKNavigationType;
68
69        /// The navigation's request.
70        #[unsafe(method(request))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn request(&self) -> Retained<NSURLRequest>;
73
74        /// A value indicating whether the web content used a download attribute to indicate that this should be downloaded.
75        #[unsafe(method(shouldPerformDownload))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn shouldPerformDownload(&self) -> bool;
78
79        #[cfg(feature = "objc2-app-kit")]
80        #[cfg(target_os = "macos")]
81        /// The modifier keys that were in effect when the navigation was requested.
82        #[unsafe(method(modifierFlags))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn modifierFlags(&self) -> NSEventModifierFlags;
85
86        /// The number of the mouse button causing the navigation to be requested.
87        #[unsafe(method(buttonNumber))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn buttonNumber(&self) -> NSInteger;
90    );
91}
92
93/// Methods declared on superclass `NSObject`.
94impl WKNavigationAction {
95    extern_methods!(
96        #[unsafe(method(init))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
99
100        #[unsafe(method(new))]
101        #[unsafe(method_family = new)]
102        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
103    );
104}