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
52extern_conformance!(
53    unsafe impl NSObjectProtocol for WKNavigationAction {}
54);
55
56impl WKNavigationAction {
57    extern_methods!(
58        #[cfg(feature = "WKFrameInfo")]
59        /// The target frame, or nil if this is a new window navigation.
60        #[unsafe(method(targetFrame))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn targetFrame(&self) -> Option<Retained<WKFrameInfo>>;
63
64        /// The type of action that triggered the navigation.
65        ///
66        /// The value is one of the constants of the enumerated type WKNavigationType.
67        #[unsafe(method(navigationType))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn navigationType(&self) -> WKNavigationType;
70
71        /// The navigation's request.
72        #[unsafe(method(request))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn request(&self) -> Retained<NSURLRequest>;
75
76        /// A value indicating whether the web content used a download attribute to indicate that this should be downloaded.
77        #[unsafe(method(shouldPerformDownload))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn shouldPerformDownload(&self) -> bool;
80
81        #[cfg(feature = "objc2-app-kit")]
82        #[cfg(target_os = "macos")]
83        /// The modifier keys that were in effect when the navigation was requested.
84        #[unsafe(method(modifierFlags))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn modifierFlags(&self) -> NSEventModifierFlags;
87
88        /// The number of the mouse button causing the navigation to be requested.
89        #[unsafe(method(buttonNumber))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn buttonNumber(&self) -> NSInteger;
92    );
93}
94
95/// Methods declared on superclass `NSObject`.
96impl WKNavigationAction {
97    extern_methods!(
98        #[unsafe(method(init))]
99        #[unsafe(method_family = init)]
100        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
101
102        #[unsafe(method(new))]
103        #[unsafe(method_family = new)]
104        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
105    );
106}