objc2-browser-engine-kit 0.3.2

Bindings to the BrowserEngineKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
use objc2_ui_kit::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/betextinteraction?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct BETextInteraction;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for BETextInteraction {}
);

extern_conformance!(
    unsafe impl UIInteraction for BETextInteraction {}
);

impl BETextInteraction {
    extern_methods!(
        #[cfg(feature = "BETextInteractionDelegate")]
        /// Assign a delegate to this object to receive callback information
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn BETextInteractionDelegate>>>;

        #[cfg(feature = "BETextInteractionDelegate")]
        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn BETextInteractionDelegate>>,
        );

        #[cfg(feature = "objc2-core-foundation")]
        /// Presents a sheet to add a text replacement shortcut to the keyboard dictionary
        ///
        /// Generally used for IME languages, such as Chinese/Japanese
        #[unsafe(method(addShortcutForText:fromRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addShortcutForText_fromRect(
            &self,
            text: &NSString,
            presentation_rect: CGRect,
        );

        #[cfg(feature = "objc2-core-foundation")]
        /// Presents a share sheet for the `text` positioned relative to the `presentationRect`
        #[unsafe(method(shareText:fromRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shareText_fromRect(&self, text: &NSString, presentation_rect: CGRect);

        #[cfg(feature = "objc2-core-foundation")]
        /// Presents a dictionary definition view for the `textWithContext` positioned relative to the `presentationRect`
        #[unsafe(method(showDictionaryForTextInContext:definingTextInRange:fromRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn showDictionaryForTextInContext_definingTextInRange_fromRect(
            &self,
            text_with_context: &NSString,
            range: NSRange,
            presentation_rect: CGRect,
        );

        #[cfg(feature = "objc2-core-foundation")]
        /// Presents a translation view for the `text` positioned relative to the `presentationRect`
        #[unsafe(method(translateText:fromRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn translateText_fromRect(&self, text: &NSString, presentation_rect: CGRect);

        /// Displays the inline text replacement UI for the current selection.
        /// For example, inline text replacements are displayed in response to the "Replace..." option in the edit menu.
        ///
        /// Could be invoked when handling `promptForReplace:` action
        #[unsafe(method(showReplacementsForText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn showReplacementsForText(&self, text: &NSString);

        /// Converts the text selection between traditional and simplified Chinese
        ///
        /// Could be invoked when handling `transliterateChinese` action
        #[unsafe(method(transliterateChineseForText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn transliterateChineseForText(&self, text: &NSString);

        /// Presents an edit menu for the current text selection
        #[unsafe(method(presentEditMenuForSelection))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentEditMenuForSelection(&self);

        /// Dismisses an edit menu for the current text selection
        #[unsafe(method(dismissEditMenuForSelection))]
        #[unsafe(method_family = none)]
        pub unsafe fn dismissEditMenuForSelection(&self);

        /// Tells the system that the document's editability status has changed.
        ///
        /// In response, the system refreshes the text interaction gestures, depending on the value of `isEditable`
        #[unsafe(method(editabilityChanged))]
        #[unsafe(method_family = none)]
        pub unsafe fn editabilityChanged(&self);

        /// Tells the system to refresh the keyboard UI.
        ///
        /// This lightweight method refreshes the selection UI.  For example, this could be invoked in response to
        /// programmatic text selection changes, independent of text interaction gestures
        #[unsafe(method(refreshKeyboardUI))]
        #[unsafe(method_family = none)]
        pub unsafe fn refreshKeyboardUI(&self);

        #[cfg(all(feature = "BETextSelectionTypes", feature = "objc2-core-foundation"))]
        /// Tells the system that the selection change has been handled for the given `point` and gesture.
        ///
        /// Should be invoked in response to:
        /// -[BETextInput updateCurrentSelectionTo:fromGesture:inState:]
        #[unsafe(method(selectionChangedWithGestureAtPoint:gesture:state:flags:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionChangedWithGestureAtPoint_gesture_state_flags(
            &self,
            point: CGPoint,
            gesture_type: BEGestureType,
            gesture_state: UIGestureRecognizerState,
            flags: BESelectionFlags,
        );

        #[cfg(all(feature = "BETextSelectionTypes", feature = "objc2-core-foundation"))]
        /// Tells the system the selection adjustment has been handled for the given `point` and touch
        ///
        /// Should be invoked in response to:
        /// -[BETextInput adjustSelectionBoundaryToPoint:touchPhase:baseIsStart:flags:]
        #[unsafe(method(selectionBoundaryAdjustedToPoint:touchPhase:flags:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionBoundaryAdjustedToPoint_touchPhase_flags(
            &self,
            point: CGPoint,
            touch: BESelectionTouchPhase,
            flags: BESelectionFlags,
        );

        /// Returns a UITextSelectionDisplayInteraction that manages selection UI
        #[unsafe(method(textSelectionDisplayInteraction))]
        #[unsafe(method_family = none)]
        pub unsafe fn textSelectionDisplayInteraction(
            &self,
        ) -> Retained<UITextSelectionDisplayInteraction>;

        /// Set a delegate to receive callbacks for the context menu interaction
        #[unsafe(method(contextMenuInteractionDelegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn contextMenuInteractionDelegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UIContextMenuInteractionDelegate>>>;

        /// Setter for [`contextMenuInteractionDelegate`][Self::contextMenuInteractionDelegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setContextMenuInteractionDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setContextMenuInteractionDelegate(
            &self,
            context_menu_interaction_delegate: Option<
                &ProtocolObject<dyn UIContextMenuInteractionDelegate>,
            >,
        );

        /// Returns a UIContextMenuInteraction object whose delegate methods will be invoked
        /// on `contextMenuInteractionDelegate`
        #[unsafe(method(contextMenuInteraction))]
        #[unsafe(method_family = none)]
        pub unsafe fn contextMenuInteraction(&self) -> Retained<UIContextMenuInteraction>;
    );
}

/// Methods declared on superclass `NSObject`.
impl BETextInteraction {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}