Ejemplo n.º 1
0
 partial void onEnableF2(NSObject sender)
 {
     if (f2Shortcut == null)
     {
         enableF2.Title       = "Disable Cmd-F2";
         infoText.StringValue = "Cmd-F2 is enabled";
         MASShortcut shortcut2 = new MASShortcut(Keycode.kVK_F2, EventModifier.NSCommandKeyMask);
         f2Shortcut = MASShortcut.AddGlobalHotkeyMonitor(shortcut2, callback);
     }
     else
     {
         enableF2.Title       = "Enable Cmd-F2";
         infoText.StringValue = "Cmd-F2 is disabled";
         MASShortcut.RemoveGlobalHotkeyMonitor(f2Shortcut);
         f2Shortcut = null;
     }
 }
Ejemplo n.º 2
0
partial         void onEnableF2(NSObject sender)
        {
            if (f2Shortcut == null)
            {
                enableF2.Title = "Disable Cmd-F2";
                infoText.StringValue = "Cmd-F2 is enabled";
                MASShortcut shortcut2 = new MASShortcut(Keycode.kVK_F2, EventModifier.NSCommandKeyMask);
                f2Shortcut = MASShortcut.AddGlobalHotkeyMonitor(shortcut2, callback);
            }
            else
            {
                enableF2.Title = "Enable Cmd-F2";
                infoText.StringValue = "Cmd-F2 is disabled";
                MASShortcut.RemoveGlobalHotkeyMonitor(f2Shortcut);
                f2Shortcut = null;
            }
        }
Ejemplo n.º 3
0
 partial void onEnableF1(NSObject sender)
 {
     if (f1Shortcut == null)
     {
         enableF1.Title       = "Disable Cmd-F1";
         infoText.StringValue = "Cmd-F1 is enabled";
         MASShortcut shortcut1 = new MASShortcut(Keycode.kVK_F1, EventModifier.NSCommandKeyMask);
         f1Shortcut = MASShortcut.AddGlobalHotkeyMonitor(shortcut1,
                                                         delegate {
             infoText.StringValue = "Cmd-F1 pressed";
         });
     }
     else
     {
         enableF1.Title       = "Enable Cmd-F1";
         infoText.StringValue = "Cmd-F1 is disabled";
         MASShortcut.RemoveGlobalHotkeyMonitor(f1Shortcut);
         f1Shortcut = null;
     }
 }
Ejemplo n.º 4
0
partial         void onEnableF1(NSObject sender)
        {
            if (f1Shortcut == null)
            {
                enableF1.Title = "Disable Cmd-F1";
                infoText.StringValue = "Cmd-F1 is enabled";
                MASShortcut shortcut1 = new MASShortcut(Keycode.kVK_F1, EventModifier.NSCommandKeyMask);
                f1Shortcut = MASShortcut.AddGlobalHotkeyMonitor(shortcut1,
                delegate {
                    infoText.StringValue = "Cmd-F1 pressed";
                });
            }
            else
            {
                enableF1.Title = "Enable Cmd-F1";
                infoText.StringValue = "Cmd-F1 is disabled";
                MASShortcut.RemoveGlobalHotkeyMonitor(f1Shortcut);
                f1Shortcut = null;
            }
        }
Ejemplo n.º 5
0
        public override void FinishedLaunching(NSObject notification)
        {
            allowed = new List <string> {
                "alert:", "notify:", "showPopup:", "resize:", "setUserAgent:", "setPinned:", "setHotkey:", "isVisible:", "quit:", "openSite:"
            };

            this.window.Level           = NSWindowLevel.Floating;
            this.window.IsOpaque        = false;
            this.window.BackgroundColor = NSColor.Clear;
            this.window.DidResignKey   += (object sender, EventArgs e) => { if (!pinned)
                                                                            {
                                                                                ShowPopup(false);
                                                                            }
            };

            var wv = this.webview2;

            wv.WantsLayer          = true;
            wv.Layer.CornerRadius  = 5;
            wv.Layer.MasksToBounds = true;
            wv.DrawsBackground     = false;

            // Set webscript object
            wv.WindowScriptObject.SetValueForKey(this, new NSString("tray"));
            wv.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl("file:///Users/emilebosch/dev/z/osx-traykit/menubar/App/Index.html")));

            statusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
            statusItem.Title         = "!";
            statusItem.HighlightMode = true;
            statusItem.Action        = new Selector("HandleMenu");

            var menu = new NSMenu();

            menu.AddItem(new NSMenuItem("Quit", (e, v) => { Quit(); }));
            menu.AddItem(new NSMenuItem("Open Site..", (e, v) => { OpenSite(); }));

            MASShortcut.AddGlobalHotkeyMonitor(new MASShortcut(Keycode.kVK_F12, EventModifier.NSCommandKeyMask), delegate { ShowPopup(!IsVisible()); });
            MASShortcut.AddGlobalHotkeyMonitor(new MASShortcut(Keycode.kVK_F11, EventModifier.NSCommandKeyMask), delegate { statusItem.PopUpStatusItemMenu(menu); });
        }
Ejemplo n.º 6
0
 public void SetHotkey(MonoMac.WebKit.WebScriptObject wo)
 {
     MASShortcut.AddGlobalHotkeyMonitor(new MASShortcut(Keycode.kVK_F1, EventModifier.NSCommandKeyMask), delegate {
         wo.CallWebScriptMethod("cb", new NSObject[] { });
     });
 }