#[repr(C)]pub struct NSVisualEffectViewTagged { /* private fields */ }
Expand description
A custom NSVisualEffectView subclass that overrides the tag method to provide a custom tag, to later identify the view
Implementations§
Source§impl NSVisualEffectViewTagged
impl NSVisualEffectViewTagged
Sourcepub unsafe fn initWithFrame(
this: Allocated<Self>,
frame_rect: NSRect,
tag: NSInteger,
) -> Retained<Self>
pub unsafe fn initWithFrame( this: Allocated<Self>, frame_rect: NSRect, tag: NSInteger, ) -> Retained<Self>
§Safety
This method is unsafe because it calls an Objective-C method.
Sourcepub unsafe fn setMaterial(&self, material: NSVisualEffectMaterial)
pub unsafe fn setMaterial(&self, material: NSVisualEffectMaterial)
https://developer.apple.com/documentation/appkit/nsvisualeffectview/material-swift.property
§Safety
This method is unsafe because it calls an Objective-C method.
Sourcepub unsafe fn setBlendingMode(&self, blending_mode: NSVisualEffectBlendingMode)
pub unsafe fn setBlendingMode(&self, blending_mode: NSVisualEffectBlendingMode)
https://developer.apple.com/documentation/appkit/nsvisualeffectview/blendingmode-swift.property
§Safety
This method is unsafe because it calls an Objective-C method.
Sourcepub unsafe fn setState(&self, state: NSVisualEffectState)
pub unsafe fn setState(&self, state: NSVisualEffectState)
https://developer.apple.com/documentation/appkit/nsvisualeffectview/state-swift.property
§Safety
This method is unsafe because it calls an Objective-C method.
Sourcepub unsafe fn setAutoresizingMask(&self, mask: NSAutoresizingMaskOptions)
pub unsafe fn setAutoresizingMask(&self, mask: NSAutoresizingMaskOptions)
NSView inherited method https://developer.apple.com/documentation/appkit/nsview/autoresizingmask-swift.property
§Safety
This method is unsafe because it calls an Objective-C method.
Sourcepub unsafe fn setCornerRadius(&self, radius: CGFloat)
pub unsafe fn setCornerRadius(&self, radius: CGFloat)
TODO: Does not seem to be public? Method is not listed in Apple documentation, might be private, but it works
§Safety
This method is unsafe because it calls an Objective-C method.
Methods from Deref<Target = NSVisualEffectView>§
Sourcepub unsafe fn material(&self) -> NSVisualEffectMaterial
pub unsafe fn material(&self) -> NSVisualEffectMaterial
A value indicating which material is shown by the NSVisualEffectView. See the comments on NSVisualEffectMaterial. Defaults to NSVisualEffectMaterialAppearanceBased. You should instead specify an appropriate semantic material value. See the comments on NSVisualEffectMaterial.
Sourcepub unsafe fn setMaterial(&self, material: NSVisualEffectMaterial)
pub unsafe fn setMaterial(&self, material: NSVisualEffectMaterial)
Setter for material
.
Sourcepub unsafe fn blendingMode(&self) -> NSVisualEffectBlendingMode
pub unsafe fn blendingMode(&self) -> NSVisualEffectBlendingMode
A value controlling how the NSVisualEffectView generates its material. See the comments on NSVisualEffectBlendingMode. Not all materials support both blending modes, so NSVisualEffectView may fall back to a more appropriate blending mode as needed. Defaults to NSVisualEffectBlendingModeBehindWindow.
Sourcepub unsafe fn setBlendingMode(&self, blending_mode: NSVisualEffectBlendingMode)
pub unsafe fn setBlendingMode(&self, blending_mode: NSVisualEffectBlendingMode)
Setter for blendingMode
.
Sourcepub unsafe fn state(&self) -> NSVisualEffectState
pub unsafe fn state(&self) -> NSVisualEffectState
A value controlling when the NSVisualEffectView takes on the active look. See the comments on NSVisualEffectState. Defaults to NSVisualEffectStateFollowsWindowActiveState.
Sourcepub unsafe fn setState(&self, state: NSVisualEffectState)
pub unsafe fn setState(&self, state: NSVisualEffectState)
Setter for state
.
Sourcepub unsafe fn isEmphasized(&self) -> bool
pub unsafe fn isEmphasized(&self) -> bool
When YES, the material takes on the emphasized look. Defaults to NO. Some, but not all, materials change their look when emphasized. This is used to indicate that an associated view has firstResponder status.
Sourcepub unsafe fn setEmphasized(&self, emphasized: bool)
pub unsafe fn setEmphasized(&self, emphasized: bool)
Setter for isEmphasized
.
pub unsafe fn viewDidMoveToWindow(&self)
Methods from Deref<Target = NSView>§
pub unsafe fn superview(&self) -> Option<Retained<NSView>>
pub unsafe fn subviews(&self) -> Retained<NSArray<NSView>>
Sourcepub unsafe fn setSubviews(&self, subviews: &NSArray<NSView>)
pub unsafe fn setSubviews(&self, subviews: &NSArray<NSView>)
Setter for subviews
.
pub unsafe fn isDescendantOf(&self, view: &NSView) -> bool
pub unsafe fn opaqueAncestor(&self) -> Option<Retained<NSView>>
pub unsafe fn isHidden(&self) -> bool
pub unsafe fn isHiddenOrHasHiddenAncestor(&self) -> bool
pub unsafe fn getRectsBeingDrawn_count( &self, rects: *mut *const CGRect, count: *mut isize, )
pub unsafe fn needsToDrawRect(&self, rect: CGRect) -> bool
pub unsafe fn wantsDefaultClipping(&self) -> bool
pub unsafe fn viewDidHide(&self)
pub unsafe fn viewDidUnhide(&self)
pub unsafe fn addSubview(&self, view: &NSView)
pub unsafe fn addSubview_positioned_relativeTo( &self, view: &NSView, place: NSWindowOrderingMode, other_view: Option<&NSView>, )
pub unsafe fn sortSubviewsUsingFunction_context( &self, compare: unsafe extern "C-unwind" fn(_: NonNull<NSView>, _: NonNull<NSView>, _: *mut c_void) -> NSComparisonResult, context: *mut c_void, )
pub unsafe fn viewDidMoveToWindow(&self)
pub unsafe fn viewWillMoveToSuperview(&self, new_superview: Option<&NSView>)
pub unsafe fn viewDidMoveToSuperview(&self)
pub unsafe fn didAddSubview(&self, subview: &NSView)
pub unsafe fn willRemoveSubview(&self, subview: &NSView)
pub unsafe fn removeFromSuperview(&self)
pub unsafe fn replaceSubview_with(&self, old_view: &NSView, new_view: &NSView)
pub unsafe fn removeFromSuperviewWithoutNeedingDisplay(&self)
pub unsafe fn viewDidChangeBackingProperties(&self)
pub unsafe fn postsFrameChangedNotifications(&self) -> bool
Sourcepub fn setPostsFrameChangedNotifications(
&self,
posts_frame_changed_notifications: bool,
)
pub fn setPostsFrameChangedNotifications( &self, posts_frame_changed_notifications: bool, )
Setter for postsFrameChangedNotifications
.
pub unsafe fn resizeSubviewsWithOldSize(&self, old_size: CGSize)
pub unsafe fn resizeWithOldSuperviewSize(&self, old_size: CGSize)
pub unsafe fn autoresizesSubviews(&self) -> bool
Sourcepub unsafe fn setAutoresizesSubviews(&self, autoresizes_subviews: bool)
pub unsafe fn setAutoresizesSubviews(&self, autoresizes_subviews: bool)
Setter for autoresizesSubviews
.
pub unsafe fn autoresizingMask(&self) -> NSAutoresizingMaskOptions
Sourcepub unsafe fn setAutoresizingMask(
&self,
autoresizing_mask: NSAutoresizingMaskOptions,
)
pub unsafe fn setAutoresizingMask( &self, autoresizing_mask: NSAutoresizingMaskOptions, )
Setter for autoresizingMask
.
pub unsafe fn setFrameOrigin(&self, new_origin: CGPoint)
pub unsafe fn setFrameSize(&self, new_size: CGSize)
pub fn frame(&self) -> CGRect
pub unsafe fn setBoundsOrigin(&self, new_origin: CGPoint)
pub unsafe fn setBoundsSize(&self, new_size: CGSize)
pub unsafe fn translateOriginToPoint(&self, translation: CGPoint)
pub unsafe fn scaleUnitSquareToSize(&self, new_unit_size: CGSize)
pub fn bounds(&self) -> CGRect
pub fn isFlipped(&self) -> bool
pub unsafe fn isRotatedFromBase(&self) -> bool
pub unsafe fn isRotatedOrScaledFromBase(&self) -> bool
pub unsafe fn isOpaque(&self) -> bool
pub fn convertPoint_fromView( &self, point: CGPoint, view: Option<&NSView>, ) -> CGPoint
pub unsafe fn convertPoint_toView( &self, point: CGPoint, view: Option<&NSView>, ) -> CGPoint
pub unsafe fn convertSize_fromView( &self, size: CGSize, view: Option<&NSView>, ) -> CGSize
pub unsafe fn convertSize_toView( &self, size: CGSize, view: Option<&NSView>, ) -> CGSize
pub unsafe fn convertRect_fromView( &self, rect: CGRect, view: Option<&NSView>, ) -> CGRect
pub fn convertRect_toView(&self, rect: CGRect, view: Option<&NSView>) -> CGRect
pub unsafe fn backingAlignedRect_options( &self, rect: CGRect, options: NSAlignmentOptions, ) -> CGRect
pub unsafe fn centerScanRect(&self, rect: CGRect) -> CGRect
pub unsafe fn convertPointToBacking(&self, point: CGPoint) -> CGPoint
pub unsafe fn convertPointFromBacking(&self, point: CGPoint) -> CGPoint
pub unsafe fn convertSizeToBacking(&self, size: CGSize) -> CGSize
pub unsafe fn convertSizeFromBacking(&self, size: CGSize) -> CGSize
pub unsafe fn convertRectToBacking(&self, rect: CGRect) -> CGRect
pub unsafe fn convertRectFromBacking(&self, rect: CGRect) -> CGRect
pub unsafe fn convertPointToLayer(&self, point: CGPoint) -> CGPoint
pub unsafe fn convertPointFromLayer(&self, point: CGPoint) -> CGPoint
pub unsafe fn convertSizeToLayer(&self, size: CGSize) -> CGSize
pub unsafe fn convertSizeFromLayer(&self, size: CGSize) -> CGSize
pub unsafe fn convertRectToLayer(&self, rect: CGRect) -> CGRect
pub unsafe fn convertRectFromLayer(&self, rect: CGRect) -> CGRect
pub unsafe fn canDrawConcurrently(&self) -> bool
Sourcepub unsafe fn setCanDrawConcurrently(&self, can_draw_concurrently: bool)
pub unsafe fn setCanDrawConcurrently(&self, can_draw_concurrently: bool)
Setter for canDrawConcurrently
.
pub unsafe fn canDraw(&self) -> bool
pub unsafe fn setNeedsDisplayInRect(&self, invalid_rect: CGRect)
pub unsafe fn needsDisplay(&self) -> bool
Sourcepub unsafe fn setNeedsDisplay(&self, needs_display: bool)
pub unsafe fn setNeedsDisplay(&self, needs_display: bool)
Setter for needsDisplay
.
pub unsafe fn lockFocus(&self)
pub unsafe fn unlockFocus(&self)
pub unsafe fn lockFocusIfCanDraw(&self) -> bool
Sourcepub fn visibleRect(&self) -> CGRect
pub fn visibleRect(&self) -> CGRect
The portion of the view that isn’t clipped by its superviews.
Visibility, as reflected by this property, doesn’t account for whether other view or window objects overlap the current view or whether the current view is installed in a window at all. This value of this property is NSZeroRect
if the current view is effectively hidden.
During a printing operation, the visible rectangle is further clipped to the page being imaged.
pub unsafe fn display(&self)
pub unsafe fn displayIfNeeded(&self)
pub unsafe fn displayIfNeededIgnoringOpacity(&self)
pub unsafe fn displayRect(&self, rect: CGRect)
pub unsafe fn displayIfNeededInRect(&self, rect: CGRect)
pub unsafe fn displayRectIgnoringOpacity(&self, rect: CGRect)
pub unsafe fn displayIfNeededInRectIgnoringOpacity(&self, rect: CGRect)
pub unsafe fn drawRect(&self, dirty_rect: CGRect)
pub unsafe fn viewWillDraw(&self)
pub unsafe fn scrollPoint(&self, point: CGPoint)
pub unsafe fn scrollRectToVisible(&self, rect: CGRect) -> bool
pub unsafe fn adjustScroll(&self, new_visible: CGRect) -> CGRect
pub unsafe fn scrollRect_by(&self, rect: CGRect, delta: CGSize)
pub unsafe fn translateRectsNeedingDisplayInRect_by( &self, clip_rect: CGRect, delta: CGSize, )
pub unsafe fn hitTest(&self, point: CGPoint) -> Option<Retained<NSView>>
pub unsafe fn mouse_inRect(&self, point: CGPoint, rect: CGRect) -> bool
pub unsafe fn viewWithTag(&self, tag: isize) -> Option<Retained<NSView>>
pub unsafe fn tag(&self) -> isize
pub unsafe fn needsPanelToBecomeKey(&self) -> bool
pub unsafe fn mouseDownCanMoveWindow(&self) -> bool
pub unsafe fn acceptsTouchEvents(&self) -> bool
Sourcepub unsafe fn setAcceptsTouchEvents(&self, accepts_touch_events: bool)
👎Deprecated: Use allowedTouchTypes instead
pub unsafe fn setAcceptsTouchEvents(&self, accepts_touch_events: bool)
Setter for acceptsTouchEvents
.
pub unsafe fn wantsRestingTouches(&self) -> bool
Sourcepub unsafe fn setWantsRestingTouches(&self, wants_resting_touches: bool)
pub unsafe fn setWantsRestingTouches(&self, wants_resting_touches: bool)
Setter for wantsRestingTouches
.
pub unsafe fn layerContentsRedrawPolicy( &self, ) -> NSViewLayerContentsRedrawPolicy
Sourcepub unsafe fn setLayerContentsRedrawPolicy(
&self,
layer_contents_redraw_policy: NSViewLayerContentsRedrawPolicy,
)
pub unsafe fn setLayerContentsRedrawPolicy( &self, layer_contents_redraw_policy: NSViewLayerContentsRedrawPolicy, )
Setter for layerContentsRedrawPolicy
.
pub unsafe fn layerContentsPlacement(&self) -> NSViewLayerContentsPlacement
Sourcepub unsafe fn setLayerContentsPlacement(
&self,
layer_contents_placement: NSViewLayerContentsPlacement,
)
pub unsafe fn setLayerContentsPlacement( &self, layer_contents_placement: NSViewLayerContentsPlacement, )
Setter for layerContentsPlacement
.
pub unsafe fn wantsLayer(&self) -> bool
Sourcepub fn setWantsLayer(&self, wants_layer: bool)
pub fn setWantsLayer(&self, wants_layer: bool)
Setter for wantsLayer
.
pub unsafe fn wantsUpdateLayer(&self) -> bool
pub unsafe fn updateLayer(&self)
pub unsafe fn canDrawSubviewsIntoLayer(&self) -> bool
Sourcepub unsafe fn setCanDrawSubviewsIntoLayer(
&self,
can_draw_subviews_into_layer: bool,
)
pub unsafe fn setCanDrawSubviewsIntoLayer( &self, can_draw_subviews_into_layer: bool, )
Setter for canDrawSubviewsIntoLayer
.
pub unsafe fn layoutSubtreeIfNeeded(&self)
pub unsafe fn layout(&self)
pub unsafe fn needsLayout(&self) -> bool
Sourcepub unsafe fn setNeedsLayout(&self, needs_layout: bool)
pub unsafe fn setNeedsLayout(&self, needs_layout: bool)
Setter for needsLayout
.
pub unsafe fn layerUsesCoreImageFilters(&self) -> bool
Sourcepub unsafe fn setLayerUsesCoreImageFilters(
&self,
layer_uses_core_image_filters: bool,
)
pub unsafe fn setLayerUsesCoreImageFilters( &self, layer_uses_core_image_filters: bool, )
Setter for layerUsesCoreImageFilters
.
pub unsafe fn clipsToBounds(&self) -> bool
Sourcepub unsafe fn setClipsToBounds(&self, clips_to_bounds: bool)
pub unsafe fn setClipsToBounds(&self, clips_to_bounds: bool)
Setter for clipsToBounds
.
pub unsafe fn postsBoundsChangedNotifications(&self) -> bool
Sourcepub unsafe fn setPostsBoundsChangedNotifications(
&self,
posts_bounds_changed_notifications: bool,
)
pub unsafe fn setPostsBoundsChangedNotifications( &self, posts_bounds_changed_notifications: bool, )
Setter for postsBoundsChangedNotifications
.
pub unsafe fn toolTip(&self) -> Option<Retained<NSString>>
Sourcepub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>)
pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>)
Setter for toolTip
.
pub unsafe fn addToolTipRect_owner_userData( &self, rect: CGRect, owner: &AnyObject, data: *mut c_void, ) -> isize
pub unsafe fn removeToolTip(&self, tag: isize)
pub unsafe fn removeAllToolTips(&self)
pub unsafe fn viewWillStartLiveResize(&self)
pub unsafe fn viewDidEndLiveResize(&self)
pub unsafe fn inLiveResize(&self) -> bool
pub unsafe fn preservesContentDuringLiveResize(&self) -> bool
pub unsafe fn rectPreservedDuringLiveResize(&self) -> CGRect
pub unsafe fn rectForSmartMagnificationAtPoint_inRect( &self, location: CGPoint, visible_rect: CGRect, ) -> CGRect
pub unsafe fn prepareForReuse(&self)
pub unsafe fn prepareContentInRect(&self, rect: CGRect)
pub unsafe fn preparedContentRect(&self) -> CGRect
Sourcepub unsafe fn setPreparedContentRect(&self, prepared_content_rect: CGRect)
pub unsafe fn setPreparedContentRect(&self, prepared_content_rect: CGRect)
Setter for preparedContentRect
.
pub unsafe fn allowsVibrancy(&self) -> bool
Sourcepub unsafe fn viewDidChangeEffectiveAppearance(&self)
pub unsafe fn viewDidChangeEffectiveAppearance(&self)
Override point for reacting to the effective appearance of the receiver changing. At this point effectiveAppearance
property reflects the new appearance.
pub unsafe fn nextKeyView(&self) -> Option<Retained<NSView>>
Sourcepub unsafe fn setNextKeyView(&self, next_key_view: Option<&NSView>)
pub unsafe fn setNextKeyView(&self, next_key_view: Option<&NSView>)
Setter for nextKeyView
.
pub unsafe fn previousKeyView(&self) -> Option<Retained<NSView>>
pub unsafe fn nextValidKeyView(&self) -> Option<Retained<NSView>>
pub unsafe fn previousValidKeyView(&self) -> Option<Retained<NSView>>
pub unsafe fn canBecomeKeyView(&self) -> bool
pub unsafe fn setKeyboardFocusRingNeedsDisplayInRect(&self, rect: CGRect)
pub unsafe fn focusRingType(&self) -> NSFocusRingType
Sourcepub unsafe fn setFocusRingType(&self, focus_ring_type: NSFocusRingType)
pub unsafe fn setFocusRingType(&self, focus_ring_type: NSFocusRingType)
Setter for focusRingType
.
pub unsafe fn drawFocusRingMask(&self)
pub unsafe fn focusRingMaskBounds(&self) -> CGRect
pub unsafe fn noteFocusRingMaskChanged(&self)
pub unsafe fn dataWithEPSInsideRect(&self, rect: CGRect) -> Retained<NSData>
pub unsafe fn dataWithPDFInsideRect(&self, rect: CGRect) -> Retained<NSData>
pub unsafe fn print(&self, sender: Option<&AnyObject>)
pub unsafe fn knowsPageRange(&self, range: *mut NSRange) -> bool
pub unsafe fn rectForPage(&self, page: isize) -> CGRect
pub unsafe fn locationOfPrintRect(&self, rect: CGRect) -> CGPoint
pub unsafe fn drawPageBorderWithSize(&self, border_size: CGSize)
pub unsafe fn pageHeader(&self) -> Retained<NSAttributedString>
Sourcepub unsafe fn drawSheetBorderWithSize(&self, border_size: CGSize)
👎Deprecated: This is never invoked and the NSView implementation does nothing
pub unsafe fn drawSheetBorderWithSize(&self, border_size: CGSize)
- This method is obsolete. It will never be invoked from within AppKit, and NSView’s implementation of it does nothing. **
pub unsafe fn printJobTitle(&self) -> Retained<NSString>
pub unsafe fn beginDocument(&self)
pub unsafe fn endDocument(&self)
pub unsafe fn beginPageInRect_atPlacement( &self, rect: CGRect, location: CGPoint, )
pub unsafe fn endPage(&self)
pub unsafe fn unregisterDraggedTypes(&self)
pub unsafe fn exitFullScreenModeWithOptions( &self, options: Option<&NSDictionary<NSString>>, )
pub unsafe fn isInFullScreenMode(&self) -> bool
pub unsafe fn showDefinitionForAttributedString_atPoint( &self, attr_string: Option<&NSAttributedString>, text_baseline_origin: CGPoint, )
pub unsafe fn isDrawingFindIndicator(&self) -> bool
pub unsafe fn safeAreaInsets(&self) -> NSEdgeInsets
pub unsafe fn additionalSafeAreaInsets(&self) -> NSEdgeInsets
Sourcepub unsafe fn setAdditionalSafeAreaInsets(
&self,
additional_safe_area_insets: NSEdgeInsets,
)
pub unsafe fn setAdditionalSafeAreaInsets( &self, additional_safe_area_insets: NSEdgeInsets, )
Setter for additionalSafeAreaInsets
.
pub unsafe fn safeAreaRect(&self) -> CGRect
pub unsafe fn updateTrackingAreas(&self)
pub unsafe fn discardCursorRects(&self)
pub unsafe fn resetCursorRects(&self)
pub unsafe fn addTrackingRect_owner_userData_assumeInside( &self, rect: CGRect, owner: &AnyObject, data: *mut c_void, flag: bool, ) -> isize
pub fn removeTrackingRect(&self, tag: isize)
pub unsafe fn convertPointToBase(&self, point: CGPoint) -> CGPoint
pub unsafe fn convertPointFromBase(&self, point: CGPoint) -> CGPoint
pub unsafe fn convertSizeToBase(&self, size: CGSize) -> CGSize
pub unsafe fn convertSizeFromBase(&self, size: CGSize) -> CGSize
pub unsafe fn convertRectToBase(&self, rect: CGRect) -> CGRect
pub unsafe fn convertRectFromBase(&self, rect: CGRect) -> CGRect
pub unsafe fn performMnemonic(&self, string: &NSString) -> bool
pub unsafe fn shouldDrawColor(&self) -> bool
pub unsafe fn gState(&self) -> isize
pub unsafe fn allocateGState(&self)
pub unsafe fn setUpGState(&self)
pub unsafe fn renewGState(&self)
Methods from Deref<Target = NSResponder>§
pub unsafe fn nextResponder(&self) -> Option<Retained<NSResponder>>
Sourcepub unsafe fn setNextResponder(&self, next_responder: Option<&NSResponder>)
pub unsafe fn setNextResponder(&self, next_responder: Option<&NSResponder>)
Setter for nextResponder
.
pub unsafe fn tryToPerform_with( &self, action: Sel, object: Option<&AnyObject>, ) -> bool
pub unsafe fn noResponderFor(&self, event_selector: Sel)
pub unsafe fn acceptsFirstResponder(&self) -> bool
pub unsafe fn becomeFirstResponder(&self) -> bool
pub unsafe fn resignFirstResponder(&self) -> bool
pub unsafe fn flushBufferedKeyEvents(&self)
pub unsafe fn showContextHelp(&self, sender: Option<&AnyObject>)
pub unsafe fn supplementalTargetForAction_sender( &self, action: Sel, sender: Option<&AnyObject>, ) -> Option<Retained<AnyObject>>
pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>
pub unsafe fn presentError(&self, error: &NSError) -> bool
pub unsafe fn willPresentError(&self, error: &NSError) -> Retained<NSError>
pub unsafe fn performTextFinderAction(&self, sender: Option<&AnyObject>)
pub unsafe fn newWindowForTab(&self, sender: Option<&AnyObject>)
pub unsafe fn showWritingTools(&self, sender: Option<&AnyObject>)
pub unsafe fn performMnemonic(&self, string: &NSString) -> bool
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for NSVisualEffectViewTagged
impl AsRef<AnyObject> for NSVisualEffectViewTagged
Source§impl AsRef<NSVisualEffectView> for NSVisualEffectViewTagged
impl AsRef<NSVisualEffectView> for NSVisualEffectViewTagged
Source§fn as_ref(&self) -> &NSVisualEffectView
fn as_ref(&self) -> &NSVisualEffectView
Source§impl Borrow<AnyObject> for NSVisualEffectViewTagged
impl Borrow<AnyObject> for NSVisualEffectViewTagged
Source§impl Borrow<NSVisualEffectView> for NSVisualEffectViewTagged
impl Borrow<NSVisualEffectView> for NSVisualEffectViewTagged
Source§fn borrow(&self) -> &NSVisualEffectView
fn borrow(&self) -> &NSVisualEffectView
Source§impl ClassType for NSVisualEffectViewTagged
impl ClassType for NSVisualEffectViewTagged
Source§const NAME: &'static str = "NSVisualEffectViewTagged"
const NAME: &'static str = "NSVisualEffectViewTagged"
Source§type Super = NSVisualEffectView
type Super = NSVisualEffectView
Source§type ThreadKind = <<NSVisualEffectViewTagged as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<NSVisualEffectViewTagged as ClassType>::Super as ClassType>::ThreadKind
Source§impl Deref for NSVisualEffectViewTagged
impl Deref for NSVisualEffectViewTagged
Source§impl Message for NSVisualEffectViewTagged
impl Message for NSVisualEffectViewTagged
Source§impl RefEncode for NSVisualEffectViewTagged
impl RefEncode for NSVisualEffectViewTagged
Source§const ENCODING_REF: Encoding = <NSVisualEffectView as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSVisualEffectView as ::objc2::RefEncode>::ENCODING_REF
impl DowncastTarget for NSVisualEffectViewTagged
Auto Trait Implementations§
impl !Freeze for NSVisualEffectViewTagged
impl !RefUnwindSafe for NSVisualEffectViewTagged
impl !Send for NSVisualEffectViewTagged
impl !Sync for NSVisualEffectViewTagged
impl !Unpin for NSVisualEffectViewTagged
impl !UnwindSafe for NSVisualEffectViewTagged
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'a, T> MainThreadOnly for T
impl<'a, T> MainThreadOnly for T
Source§fn mtm(&self) -> MainThreadMarker
fn mtm(&self) -> MainThreadMarker
MainThreadMarker
from the main-thread-only object. Read more