internal static void DumpAccessibilityTree(NSObject obj = null, int indentLevel = 0)
        {
            if (obj == null)
            {
                obj = NSApplication.SharedApplication;
            }

            string desc = obj.Description;

            desc = desc.PadLeft(desc.Length + indentLevel, ' ');
            Console.WriteLine($"{desc}");

            if (!obj.RespondsToSelector(new Selector("accessibilityChildren")))
            {
                string notAccessible = "Not accessible";
                Console.WriteLine($"{notAccessible.PadLeft (notAccessible.Length + indentLevel + 2, ' ')}");
                return;
            }

            NSArray children = (NSArray)obj.PerformSelector(new Selector("accessibilityChildren"));

            if (children == null)
            {
                return;
            }

            for (nuint i = 0; i < children.Count; i++)
            {
                DumpAccessibilityTree(children.GetItem <NSObject> (i), indentLevel + 2);
            }
        }
Esempio n. 2
0
		public bool ValidateUserInterfaceItem (NSObject anItem)
		{
		 	Selector actionSelPtr = new Selector (anItem.PerformSelector (actionSel).Handle);
		 
		 	if (actionSelPtr == pasteSel)
		 		return NSPasteboard.GeneralPasteboard.CanReadObjectForClasses (new Class [] { ( new Class ("NSImage") )} , null);
		 
		 	return true;
		}
Esempio n. 3
0
        public bool ValidateUserInterfaceItem(NSObject anItem)
        {
            Selector actionSelPtr = new Selector(anItem.PerformSelector(actionSel).Handle);

            if (actionSelPtr == pasteSel)
            {
                return(NSPasteboard.GeneralPasteboard.CanReadObjectForClasses(new Class [] { (new Class("NSImage")) }, null));
            }

            return(true);
        }
Esempio n. 4
0
            public void DecidePolicyForNavigation(wk.WebView webView, NSDictionary action, NSUrlRequest request, wk.WebFrame frame, NSObject listener)
            {
                var url  = action.ObjectForKey(new NSString("WebActionOriginalURLKey")) as NSUrl;
                var args = new WebViewNewWindowEventArgs(new Uri(url.AbsoluteString), frame.Name);

                Handler.Widget.OnOpenNewWindow(args);
                if (!args.Cancel)
                {
                    NSWorkspace.SharedWorkspace.OpenUrl(url);
                }
                listener.PerformSelector(selIgnore, null, 0);
            }
        void BtnCrash_TouchUpInside(object sender, EventArgs e)
        {
            if (SwtLog.On)
            {
                CrashReporting.Log(TxtLog.Text);
            }

            // Create a Crash
            // Please, go to https://components.xamarin.com/gettingstarted/firebaseioscrashreporting
            // and follow instructions.
            var crash = new NSObject();

            crash.PerformSelector(new Selector("doesNotRecognizeSelector"), crash, 0);
        }
Esempio n. 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a GA event and dispatch it to GA.
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Dispatch", UIBarButtonItemStyle.Bordered, (s, e) => {
                var gaEvent = GAIDictionaryBuilder.CreateEvent("UI", "buttonPress", "dispatch", null).Build();
                GAI.SharedInstance.DefaultTracker.Send(gaEvent);
                GAI.SharedInstance.Dispatch();
                Console.WriteLine("Event Sent, Check Google's GA Event Console");
            });

            // Create a Crash
            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Crash", UIBarButtonItemStyle.Bordered, (s, e) => {
                var obj = new NSObject();
                obj.PerformSelector(new Selector("doesNotRecognizeSelector"), obj, 0);
            });
        }
Esempio n. 7
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// Create a GA event and dispatch it to GA.
			NavigationItem.LeftBarButtonItem = new UIBarButtonItem ("Dispatch", UIBarButtonItemStyle.Plain, (s, e) => {
				var gaEvent = GAIDictionaryBuilder.CreateEvent ("UI", "buttonPress", "dispatch", null).Build ();
				GAI.SharedInstance.DefaultTracker.Send (gaEvent);
				GAI.SharedInstance.Dispatch ();
				Console.WriteLine ("Event Sent, Check Google's GA Event Console");
			});

			// Create a Crash
			NavigationItem.RightBarButtonItem = new UIBarButtonItem ("Crash", UIBarButtonItemStyle.Plain, (s, e) => {
				var obj = new NSObject ();
				obj.PerformSelector (new Selector ("doesNotRecognizeSelector"), obj, 0);
			});
		}
Esempio n. 8
0
        public void Initialize()
        {
            statusBarObj       = Runtime.GetNSObject(Class.GetHandle("NSStatusBar"));
            systemStatusBarObj = statusBarObj.PerformSelector(new Selector("systemStatusBar"));
            statusBarItem      = Runtime.GetNSObject(IntPtr_objc_msgSend_nfloat(systemStatusBarObj.Handle, Selector.GetHandle("statusItemWithLength:"), -1));
            statusBarButton    = Runtime.GetNSObject(IntPtr_objc_msgSend(statusBarItem.Handle, Selector.GetHandle("button")));
            statusBarImage     = Runtime.GetNSObject(IntPtr_objc_msgSend(ObjCRuntime.Class.GetHandle("NSImage"), Selector.GetHandle("alloc")));

            // var imgPath = System.IO.Path.Combine(NSBundle.MainBundle.BundlePath, "Contents", "trayicon.png");
            var imgPath      = System.IO.Path.Combine(NSBundle.MainBundle.BundlePath, "Contents", "Resources", "MacCatalyst", "trayicon.png");
            var imageFileStr = NSString.CreateNative(imgPath);
            var nsImagePtr   = IntPtr_objc_msgSend_IntPtr(statusBarImage.Handle, Selector.GetHandle("initWithContentsOfFile:"), imageFileStr);

            void_objc_msgSend_IntPtr(statusBarButton.Handle, Selector.GetHandle("setImage:"), statusBarImage.Handle);
            void_objc_msgSend_bool(nsImagePtr, Selector.GetHandle("setTemplate:"), true);

            // Handle click
            void_objc_msgSend_IntPtr(statusBarButton.Handle, Selector.GetHandle("setTarget:"), this.Handle);
            void_objc_msgSend_IntPtr(statusBarButton.Handle, Selector.GetHandle("setAction:"), new Selector("handleButtonClick:").Handle);
        }