コード例 #1
0
        public static string GetString(this NSTextView self)
        {
            var selector = new ObjCRuntime.Selector("string");
            var handle   = LibObjc.IntPtr_objc_msgSend(self.Handle, selector.Handle);

            return(handle != IntPtr.Zero ? NSString.FromHandle(handle) : (string)null);
        }
コード例 #2
0
        public static NSWindow[] OrderedWindows(this NSApplication self)
        {
            var selector = new ObjCRuntime.Selector("orderedWindows");
            var ptr      = LibObjc.IntPtr_objc_msgSend(self.Handle, selector.Handle);
            var array    = NSArray.ArrayFromHandle <NSWindow>(ptr);

            return(array);
        }
コード例 #3
0
        public static NSInvocation ToInvocation(this NSMethodSignature signature)
        {
            var cls  = Class.GetHandle(typeof(NSInvocation));
            var ctor = Selector.GetHandle("invocationWithMethodSignature:");
            var inv  = LibObjc.IntPtr_objc_msgSend_IntPtr(cls, ctor, signature.Handle);

            return(ObjCRuntime.Runtime.GetNSObject <NSInvocation>(inv));
        }
コード例 #4
0
        public static Class SetCellClass(this Class ctrlClass, Class cellClass)
        {
            var cellClassHandle     = LibObjc.IntPtr_objc_msgSend(cellClass.Handle, classSel.Handle);
            var ctrlClassHandle     = LibObjc.IntPtr_objc_msgSend(ctrlClass.Handle, classSel.Handle);
            var prevCellClassHandle = LibObjc.IntPtr_objc_msgSend(ctrlClassHandle, cellClassSel.Handle);

            LibObjc.void_objc_msgSend_IntPtr(ctrlClassHandle, setCellClassSel.Handle, cellClassHandle);
            return(prevCellClassHandle == IntPtr.Zero ? (Class)null : new Class(prevCellClassHandle));
        }
コード例 #5
0
ファイル: Extensions.cs プロジェクト: emclient/mac-playground
        public static bool AddMethod(this NSObject obj, Selector selector, Delegate imp)
        {
            if (obj.RespondsToSelector(selector))
            {
                return(false);
            }

            var classHandle = obj.Class.Handle;

            return(LibObjc.class_addMethod(classHandle, selector.Handle, imp, "v@:"));
        }
コード例 #6
0
 // provider must implement NSPasteboardItemDataProvider
 public static void SetDataProviderForTypes(this NSPasteboardItem item, NSObject provider, string[] types)
 {
     var sel   = new ObjCRuntime.Selector("setDataProvider:forTypes:");
     var array = NSArray.FromStrings(types);
     var ok    = LibObjc.bool_objc_msgSend_IntPtr_IntPtr(item.Handle, sel.Handle, provider.Handle, array.Handle);
 }
コード例 #7
0
        public static void AllowsUndo(this NSTextView self, bool value)
        {
            var selector = new ObjCRuntime.Selector("setAllowsUndo:");

            LibObjc.void_objc_msgSend_Bool(self.Handle, selector.Handle, value);
        }
コード例 #8
0
        public static bool AllowsUndo(this NSTextView self)
        {
            var selector = new ObjCRuntime.Selector("allowsUndo");

            return(LibObjc.bool_objc_msgSend(self.Handle, selector.Handle));
        }
コード例 #9
0
        public static void SetString(this NSTextView self, NSString value)
        {
            var selector = new ObjCRuntime.Selector("setString:");

            LibObjc.void_objc_msgSend_IntPtr(self.Handle, selector.Handle, value.Handle);
        }
コード例 #10
0
 public static void SetArgument(this NSInvocation invocation, NSObject arg, int index)
 {
     LibObjc.void_objc_msgSend_IntPtr_nint(invocation.Handle, Selector.GetHandle("setArgument:atIndex:"), arg?.Handle ?? IntPtr.Zero, index);
 }
コード例 #11
0
        public static NSMethodSignature GetMethodSignature(this NSObject obj, Selector selector)
        {
            var sig = LibObjc.IntPtr_objc_msgSend_IntPtr(obj.Handle, Selector.GetHandle("methodSignatureForSelector:"), selector.Handle);

            return(ObjCRuntime.Runtime.GetNSObject <NSMethodSignature>(sig));
        }