use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextInteractionMode(pub NSInteger);
impl UITextInteractionMode {
#[doc(alias = "UITextInteractionModeEditable")]
pub const Editable: Self = Self(0);
#[doc(alias = "UITextInteractionModeNonEditable")]
pub const NonEditable: Self = Self(1);
}
unsafe impl Encode for UITextInteractionMode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UITextInteractionMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
pub unsafe trait UITextInteractionDelegate: NSObjectProtocol + MainThreadOnly {
#[cfg(feature = "objc2-core-foundation")]
#[optional]
#[unsafe(method(interactionShouldBegin:atPoint:))]
#[unsafe(method_family = none)]
fn interactionShouldBegin_atPoint(
&self,
interaction: &UITextInteraction,
point: CGPoint,
) -> bool;
#[optional]
#[unsafe(method(interactionWillBegin:))]
#[unsafe(method_family = none)]
fn interactionWillBegin(&self, interaction: &UITextInteraction);
#[optional]
#[unsafe(method(interactionDidEnd:))]
#[unsafe(method_family = none)]
fn interactionDidEnd(&self, interaction: &UITextInteraction);
}
);
extern_class!(
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UITextInteraction;
);
extern_conformance!(
unsafe impl NSObjectProtocol for UITextInteraction {}
);
#[cfg(feature = "UIInteraction")]
extern_conformance!(
unsafe impl UIInteraction for UITextInteraction {}
);
impl UITextInteraction {
extern_methods!(
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UITextInteractionDelegate>>>;
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UITextInteractionDelegate>>);
#[cfg(all(
feature = "UIResponder",
feature = "UITextInput",
feature = "UITextInputTraits"
))]
#[unsafe(method(textInput))]
#[unsafe(method_family = none)]
pub fn textInput(&self) -> Option<Retained<UIResponder>>;
#[cfg(all(
feature = "UIResponder",
feature = "UITextInput",
feature = "UITextInputTraits"
))]
#[unsafe(method(setTextInput:))]
#[unsafe(method_family = none)]
pub unsafe fn setTextInput(&self, text_input: Option<&UIResponder>);
#[unsafe(method(textInteractionMode))]
#[unsafe(method_family = none)]
pub fn textInteractionMode(&self) -> UITextInteractionMode;
#[cfg(feature = "UIGestureRecognizer")]
#[unsafe(method(gesturesForFailureRequirements))]
#[unsafe(method_family = none)]
pub fn gesturesForFailureRequirements(&self) -> Retained<NSArray<UIGestureRecognizer>>;
#[unsafe(method(textInteractionForMode:))]
#[unsafe(method_family = none)]
pub fn textInteractionForMode(
mode: UITextInteractionMode,
mtm: MainThreadMarker,
) -> Retained<Self>;
);
}
impl UITextInteraction {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}