Exemple #1
0
        public override Xwt.Toolkit LoadNativeToolkit()
        {
            var path = Path.GetDirectoryName(GetType().Assembly.Location);

            System.Reflection.Assembly.LoadFrom(Path.Combine(path, "Xwt.XamMac.dll"));
            var loaded = Xwt.Toolkit.Load(Xwt.ToolkitType.XamMac);

            loaded.RegisterBackend <Xwt.Backends.IDialogBackend, ThemedMacDialogBackend> ();
            loaded.RegisterBackend <Xwt.Backends.IWindowBackend, ThemedMacWindowBackend> ();
            loaded.RegisterBackend <Xwt.Backends.IAlertDialogBackend, ThemedMacAlertDialogBackend> ();


            // We require Xwt.Mac to initialize MonoMac before we can execute any code using MonoMac
            timer.Trace("Installing App Event Handlers");
            GlobalSetup();
            timer.EndTiming();

            var appDelegate = NSApplication.SharedApplication.Delegate as Xwt.Mac.AppDelegate;

            if (appDelegate != null)
            {
                appDelegate.Terminating += (object o, TerminationEventArgs e) => {
                    if (MonoDevelop.Ide.IdeApp.IsRunning)
                    {
                        // If GLib the mainloop is still running that means NSApplication.Terminate() was called
                        // before Gtk.Application.Quit(). Cancel Cocoa termination and exit the mainloop.
                        e.Reply = NSApplicationTerminateReply.Cancel;
                        Gtk.Main.Quit();
                    }
                    else
                    {
                        // The mainloop has already exited and we've already cleaned up our application state
                        // so it's now safe to terminate Cocoa.
                        e.Reply = NSApplicationTerminateReply.Now;
                    }
                };
            }

            // Now that Cocoa has been initialized we can check whether the keyboard focus mode is turned on
            // See System Preferences - Keyboard - Shortcuts - Full Keyboard Access
            var keyboardMode = NSUserDefaults.StandardUserDefaults.IntForKey("AppleKeyboardUIMode");

            // 0 - Text boxes and lists only
            // 2 - All controls
            // 3 - All controls + keyboard access
            if (keyboardMode != 0)
            {
                Gtk.Rc.ParseString("style \"default\" { engine \"xamarin\" { focusstyle = 2 } }");
                Gtk.Rc.ParseString("style \"radio-or-check-box\" { engine \"xamarin\" { focusstyle = 2 } } ");
            }

            return(loaded);
        }
Exemple #2
0
        public override Xwt.Toolkit LoadNativeToolkit()
        {
            var path = Path.GetDirectoryName(GetType().Assembly.Location);

            System.Reflection.Assembly.LoadFrom(Path.Combine(path, "Xwt.XamMac.dll"));
            var loaded = Xwt.Toolkit.Load(Xwt.ToolkitType.XamMac);

            loaded.RegisterBackend <Xwt.Backends.IDialogBackend, ThemedMacDialogBackend> ();
            loaded.RegisterBackend <Xwt.Backends.IWindowBackend, ThemedMacWindowBackend> ();
            loaded.RegisterBackend <Xwt.Backends.IAlertDialogBackend, ThemedMacAlertDialogBackend> ();


            // We require Xwt.Mac to initialize MonoMac before we can execute any code using MonoMac
            timer.Trace("Installing App Event Handlers");
            GlobalSetup();
            timer.EndTiming();

            return(loaded);
        }
Exemple #3
0
        public override Xwt.Toolkit LoadNativeToolkit()
        {
            var path = Path.GetDirectoryName(GetType().Assembly.Location);

            System.Reflection.Assembly.LoadFrom(Path.Combine(path, "Xwt.XamMac.dll"));
            var loaded = Xwt.Toolkit.Load(Xwt.ToolkitType.XamMac);

            loaded.RegisterBackend <Xwt.Backends.IDialogBackend, ThemedMacDialogBackend> ();
            loaded.RegisterBackend <Xwt.Backends.IWindowBackend, ThemedMacWindowBackend> ();
            loaded.RegisterBackend <Xwt.Backends.IAlertDialogBackend, ThemedMacAlertDialogBackend> ();


            // We require Xwt.Mac to initialize MonoMac before we can execute any code using MonoMac
            timer.Trace("Installing App Event Handlers");
            GlobalSetup();
            timer.EndTiming();

            var appDelegate = NSApplication.SharedApplication.Delegate as Xwt.Mac.AppDelegate;

            if (appDelegate != null)
            {
                appDelegate.Terminating += (object o, TerminationEventArgs e) => {
                    if (MonoDevelop.Ide.IdeApp.IsRunning)
                    {
                        // If GLib the mainloop is still running that means NSApplication.Terminate() was called
                        // before Gtk.Application.Quit(). Cancel Cocoa termination and exit the mainloop.
                        e.Reply = NSApplicationTerminateReply.Cancel;
                        Gtk.Main.Quit();
                    }
                    else
                    {
                        // The mainloop has already exited and we've already cleaned up our application state
                        // so it's now safe to terminate Cocoa.
                        e.Reply = NSApplicationTerminateReply.Now;
                    }
                };
            }

            return(loaded);
        }