use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextBorderStyle(pub NSInteger);
impl UITextBorderStyle {
#[doc(alias = "UITextBorderStyleNone")]
pub const None: Self = Self(0);
#[doc(alias = "UITextBorderStyleLine")]
pub const Line: Self = Self(1);
#[doc(alias = "UITextBorderStyleBezel")]
pub const Bezel: Self = Self(2);
#[doc(alias = "UITextBorderStyleRoundedRect")]
pub const RoundedRect: Self = Self(3);
}
unsafe impl Encode for UITextBorderStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UITextBorderStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextFieldViewMode(pub NSInteger);
impl UITextFieldViewMode {
#[doc(alias = "UITextFieldViewModeNever")]
pub const Never: Self = Self(0);
#[doc(alias = "UITextFieldViewModeWhileEditing")]
pub const WhileEditing: Self = Self(1);
#[doc(alias = "UITextFieldViewModeUnlessEditing")]
pub const UnlessEditing: Self = Self(2);
#[doc(alias = "UITextFieldViewModeAlways")]
pub const Always: Self = Self(3);
}
unsafe impl Encode for UITextFieldViewMode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UITextFieldViewMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITextFieldDidEndEditingReason(pub NSInteger);
impl UITextFieldDidEndEditingReason {
#[doc(alias = "UITextFieldDidEndEditingReasonCommitted")]
pub const Committed: Self = Self(0);
#[doc(alias = "UITextFieldDidEndEditingReasonCancelled")]
pub const Cancelled: Self = Self(1);
}
unsafe impl Encode for UITextFieldDidEndEditingReason {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UITextFieldDidEndEditingReason {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
pub struct UITextField;
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl ClassType for UITextField {
#[inherits(UIView, UIResponder, NSObject)]
type Super = UIControl;
type Mutability = MainThreadOnly;
}
);
#[cfg(all(
feature = "UIControl",
feature = "UIResponder",
feature = "UIView",
feature = "objc2-quartz-core"
))]
#[cfg(not(target_os = "watchos"))]
unsafe impl CALayerDelegate for UITextField {}
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl NSCoding for UITextField {}
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl NSObjectProtocol for UITextField {}
#[cfg(all(
feature = "UIAppearance",
feature = "UIControl",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UIAppearance for UITextField {}
#[cfg(all(
feature = "UIAppearance",
feature = "UIControl",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UIAppearanceContainer for UITextField {}
#[cfg(all(
feature = "UIContentSizeCategoryAdjusting",
feature = "UIControl",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UIContentSizeCategoryAdjusting for UITextField {}
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UICoordinateSpace for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIDynamicBehavior",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UIDynamicItem for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIFocus",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UIFocusEnvironment for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIFocus",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UIFocusItem for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIFocus",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UIFocusItemContainer for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIResponder",
feature = "UITextInput",
feature = "UITextInputTraits",
feature = "UIView"
))]
unsafe impl UIKeyInput for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UILetterformAwareAdjusting",
feature = "UIResponder",
feature = "UIView"
))]
unsafe impl UILetterformAwareAdjusting for UITextField {}
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UIResponderStandardEditActions for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIResponder",
feature = "UITextInput",
feature = "UITextInputTraits",
feature = "UIView"
))]
unsafe impl UITextInput for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIResponder",
feature = "UITextInputTraits",
feature = "UIView"
))]
unsafe impl UITextInputTraits for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIResponder",
feature = "UITraitCollection",
feature = "UIView"
))]
unsafe impl UITraitEnvironment for UITextField {}
extern_methods!(
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UITextField {
#[method_id(@__retain_semantics Other text)]
pub unsafe fn text(&self) -> Option<Retained<NSString>>;
#[method(setText:)]
pub unsafe fn setText(&self, text: Option<&NSString>);
#[method_id(@__retain_semantics Other attributedText)]
pub unsafe fn attributedText(&self) -> Option<Retained<NSAttributedString>>;
#[method(setAttributedText:)]
pub unsafe fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);
#[cfg(feature = "UIColor")]
#[method_id(@__retain_semantics Other textColor)]
pub unsafe fn textColor(&self) -> Option<Retained<UIColor>>;
#[cfg(feature = "UIColor")]
#[method(setTextColor:)]
pub unsafe fn setTextColor(&self, text_color: Option<&UIColor>);
#[cfg(feature = "UIFont")]
#[method_id(@__retain_semantics Other font)]
pub unsafe fn font(&self) -> Option<Retained<UIFont>>;
#[cfg(feature = "UIFont")]
#[method(setFont:)]
pub unsafe fn setFont(&self, font: Option<&UIFont>);
#[cfg(feature = "NSText")]
#[method(textAlignment)]
pub unsafe fn textAlignment(&self) -> NSTextAlignment;
#[cfg(feature = "NSText")]
#[method(setTextAlignment:)]
pub unsafe fn setTextAlignment(&self, text_alignment: NSTextAlignment);
#[method(borderStyle)]
pub unsafe fn borderStyle(&self) -> UITextBorderStyle;
#[method(setBorderStyle:)]
pub unsafe fn setBorderStyle(&self, border_style: UITextBorderStyle);
#[method_id(@__retain_semantics Other defaultTextAttributes)]
pub unsafe fn defaultTextAttributes(
&self,
) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
#[method(setDefaultTextAttributes:)]
pub unsafe fn setDefaultTextAttributes(
&self,
default_text_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
);
#[method_id(@__retain_semantics Other placeholder)]
pub unsafe fn placeholder(&self) -> Option<Retained<NSString>>;
#[method(setPlaceholder:)]
pub unsafe fn setPlaceholder(&self, placeholder: Option<&NSString>);
#[method_id(@__retain_semantics Other attributedPlaceholder)]
pub unsafe fn attributedPlaceholder(&self) -> Option<Retained<NSAttributedString>>;
#[method(setAttributedPlaceholder:)]
pub unsafe fn setAttributedPlaceholder(
&self,
attributed_placeholder: Option<&NSAttributedString>,
);
#[method(clearsOnBeginEditing)]
pub unsafe fn clearsOnBeginEditing(&self) -> bool;
#[method(setClearsOnBeginEditing:)]
pub unsafe fn setClearsOnBeginEditing(&self, clears_on_begin_editing: bool);
#[method(adjustsFontSizeToFitWidth)]
pub unsafe fn adjustsFontSizeToFitWidth(&self) -> bool;
#[method(setAdjustsFontSizeToFitWidth:)]
pub unsafe fn setAdjustsFontSizeToFitWidth(&self, adjusts_font_size_to_fit_width: bool);
#[method(minimumFontSize)]
pub unsafe fn minimumFontSize(&self) -> CGFloat;
#[method(setMinimumFontSize:)]
pub unsafe fn setMinimumFontSize(&self, minimum_font_size: CGFloat);
#[method_id(@__retain_semantics Other delegate)]
pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UITextFieldDelegate>>>;
#[method(setDelegate:)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn UITextFieldDelegate>>,
);
#[cfg(feature = "UIImage")]
#[method_id(@__retain_semantics Other background)]
pub unsafe fn background(&self) -> Option<Retained<UIImage>>;
#[cfg(feature = "UIImage")]
#[method(setBackground:)]
pub unsafe fn setBackground(&self, background: Option<&UIImage>);
#[cfg(feature = "UIImage")]
#[method_id(@__retain_semantics Other disabledBackground)]
pub unsafe fn disabledBackground(&self) -> Option<Retained<UIImage>>;
#[cfg(feature = "UIImage")]
#[method(setDisabledBackground:)]
pub unsafe fn setDisabledBackground(&self, disabled_background: Option<&UIImage>);
#[method(isEditing)]
pub unsafe fn isEditing(&self) -> bool;
#[method(allowsEditingTextAttributes)]
pub unsafe fn allowsEditingTextAttributes(&self) -> bool;
#[method(setAllowsEditingTextAttributes:)]
pub unsafe fn setAllowsEditingTextAttributes(&self, allows_editing_text_attributes: bool);
#[method_id(@__retain_semantics Other typingAttributes)]
pub unsafe fn typingAttributes(
&self,
) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
#[method(setTypingAttributes:)]
pub unsafe fn setTypingAttributes(
&self,
typing_attributes: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
);
#[method(clearButtonMode)]
pub unsafe fn clearButtonMode(&self) -> UITextFieldViewMode;
#[method(setClearButtonMode:)]
pub unsafe fn setClearButtonMode(&self, clear_button_mode: UITextFieldViewMode);
#[method_id(@__retain_semantics Other leftView)]
pub unsafe fn leftView(&self) -> Option<Retained<UIView>>;
#[method(setLeftView:)]
pub unsafe fn setLeftView(&self, left_view: Option<&UIView>);
#[method(leftViewMode)]
pub unsafe fn leftViewMode(&self) -> UITextFieldViewMode;
#[method(setLeftViewMode:)]
pub unsafe fn setLeftViewMode(&self, left_view_mode: UITextFieldViewMode);
#[method_id(@__retain_semantics Other rightView)]
pub unsafe fn rightView(&self) -> Option<Retained<UIView>>;
#[method(setRightView:)]
pub unsafe fn setRightView(&self, right_view: Option<&UIView>);
#[method(rightViewMode)]
pub unsafe fn rightViewMode(&self) -> UITextFieldViewMode;
#[method(setRightViewMode:)]
pub unsafe fn setRightViewMode(&self, right_view_mode: UITextFieldViewMode);
#[method(borderRectForBounds:)]
pub unsafe fn borderRectForBounds(&self, bounds: CGRect) -> CGRect;
#[method(textRectForBounds:)]
pub unsafe fn textRectForBounds(&self, bounds: CGRect) -> CGRect;
#[method(placeholderRectForBounds:)]
pub unsafe fn placeholderRectForBounds(&self, bounds: CGRect) -> CGRect;
#[method(editingRectForBounds:)]
pub unsafe fn editingRectForBounds(&self, bounds: CGRect) -> CGRect;
#[method(clearButtonRectForBounds:)]
pub unsafe fn clearButtonRectForBounds(&self, bounds: CGRect) -> CGRect;
#[method(leftViewRectForBounds:)]
pub unsafe fn leftViewRectForBounds(&self, bounds: CGRect) -> CGRect;
#[method(rightViewRectForBounds:)]
pub unsafe fn rightViewRectForBounds(&self, bounds: CGRect) -> CGRect;
#[deprecated = "This method is no longer called."]
#[method(drawTextInRect:)]
pub unsafe fn drawTextInRect(&self, rect: CGRect);
#[method(drawPlaceholderInRect:)]
pub unsafe fn drawPlaceholderInRect(&self, rect: CGRect);
#[method_id(@__retain_semantics Other inputView)]
pub unsafe fn inputView(&self) -> Option<Retained<UIView>>;
#[method(setInputView:)]
pub unsafe fn setInputView(&self, input_view: Option<&UIView>);
#[method_id(@__retain_semantics Other inputAccessoryView)]
pub unsafe fn inputAccessoryView(&self) -> Option<Retained<UIView>>;
#[method(setInputAccessoryView:)]
pub unsafe fn setInputAccessoryView(&self, input_accessory_view: Option<&UIView>);
#[method(clearsOnInsertion)]
pub unsafe fn clearsOnInsertion(&self) -> bool;
#[method(setClearsOnInsertion:)]
pub unsafe fn setClearsOnInsertion(&self, clears_on_insertion: bool);
}
);
extern_methods!(
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UITextField {
#[method_id(@__retain_semantics Init initWithFrame:)]
pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
#[method_id(@__retain_semantics Init initWithCoder:)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
#[method_id(@__retain_semantics Init initWithFrame:primaryAction:)]
pub unsafe fn initWithFrame_primaryAction(
this: Allocated<Self>,
frame: CGRect,
primary_action: Option<&UIAction>,
) -> Retained<Self>;
}
);
extern_methods!(
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UITextField {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[method_id(@__retain_semantics New new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
}
);
extern_methods!(
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UITextField {}
);
#[cfg(all(
feature = "UIControl",
feature = "UIResponder",
feature = "UITextDragging",
feature = "UITextInput",
feature = "UITextInputTraits",
feature = "UIView"
))]
unsafe impl UITextDraggable for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIPasteConfigurationSupporting",
feature = "UIResponder",
feature = "UITextDropping",
feature = "UITextInput",
feature = "UITextInputTraits",
feature = "UITextPasteConfigurationSupporting",
feature = "UIView"
))]
unsafe impl UITextDroppable for UITextField {}
#[cfg(all(
feature = "UIControl",
feature = "UIPasteConfigurationSupporting",
feature = "UIResponder",
feature = "UITextPasteConfigurationSupporting",
feature = "UIView"
))]
unsafe impl UITextPasteConfigurationSupporting for UITextField {}
extern_methods!(
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
unsafe impl UITextField {
#[method_id(@__retain_semantics Other interactionState)]
pub unsafe fn interactionState(&self) -> Retained<AnyObject>;
#[method(setInteractionState:)]
pub unsafe fn setInteractionState(&self, interaction_state: &AnyObject);
}
);
extern_methods!(
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
unsafe impl UIView {
#[method(endEditing:)]
pub unsafe fn endEditing(&self, force: bool) -> bool;
}
);
extern_protocol!(
pub unsafe trait UITextFieldDelegate: NSObjectProtocol + IsMainThreadOnly {
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldShouldBeginEditing:)]
unsafe fn textFieldShouldBeginEditing(&self, text_field: &UITextField) -> bool;
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldDidBeginEditing:)]
unsafe fn textFieldDidBeginEditing(&self, text_field: &UITextField);
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldShouldEndEditing:)]
unsafe fn textFieldShouldEndEditing(&self, text_field: &UITextField) -> bool;
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldDidEndEditing:)]
unsafe fn textFieldDidEndEditing(&self, text_field: &UITextField);
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldDidEndEditing:reason:)]
unsafe fn textFieldDidEndEditing_reason(
&self,
text_field: &UITextField,
reason: UITextFieldDidEndEditingReason,
);
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textField:shouldChangeCharactersInRange:replacementString:)]
unsafe fn textField_shouldChangeCharactersInRange_replacementString(
&self,
text_field: &UITextField,
range: NSRange,
string: &NSString,
) -> bool;
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldDidChangeSelection:)]
unsafe fn textFieldDidChangeSelection(&self, text_field: &UITextField);
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldShouldClear:)]
unsafe fn textFieldShouldClear(&self, text_field: &UITextField) -> bool;
#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
#[optional]
#[method(textFieldShouldReturn:)]
unsafe fn textFieldShouldReturn(&self, text_field: &UITextField) -> bool;
#[cfg(all(
feature = "UIControl",
feature = "UIMenu",
feature = "UIMenuElement",
feature = "UIResponder",
feature = "UIView"
))]
#[optional]
#[method_id(@__retain_semantics Other textField:editMenuForCharactersInRange:suggestedActions:)]
unsafe fn textField_editMenuForCharactersInRange_suggestedActions(
&self,
text_field: &UITextField,
range: NSRange,
suggested_actions: &NSArray<UIMenuElement>,
) -> Option<Retained<UIMenu>>;
#[cfg(all(
feature = "UIControl",
feature = "UIEditMenuInteraction",
feature = "UIResponder",
feature = "UIView"
))]
#[optional]
#[method(textField:willPresentEditMenuWithAnimator:)]
unsafe fn textField_willPresentEditMenuWithAnimator(
&self,
text_field: &UITextField,
animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
);
#[cfg(all(
feature = "UIControl",
feature = "UIEditMenuInteraction",
feature = "UIResponder",
feature = "UIView"
))]
#[optional]
#[method(textField:willDismissEditMenuWithAnimator:)]
unsafe fn textField_willDismissEditMenuWithAnimator(
&self,
text_field: &UITextField,
animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
);
}
unsafe impl ProtocolType for dyn UITextFieldDelegate {}
);
extern "C" {
pub static UITextFieldTextDidBeginEditingNotification: &'static NSNotificationName;
}
extern "C" {
pub static UITextFieldTextDidEndEditingNotification: &'static NSNotificationName;
}
extern "C" {
pub static UITextFieldTextDidChangeNotification: &'static NSNotificationName;
}
extern "C" {
pub static UITextFieldDidEndEditingReasonKey: &'static NSString;
}