In the Main.storyboard drag two Push Buttons onto the Preferences window. When prompted select Copy items if needed. Click Add Other and navigate to the root directory of your project, then go to Carthage > Build > Mac > highlight amework and click Open.
Mac hotkey inspect update#
To do this go to the project directory and run carthage update & carthage build -platform MacOS.īack in Xcode link the new HotKey binary to our app.Ĭlick the GlobalConfigKeybind with the blue page icon, select the app Target and click the + icon under Embedded Binaries.
Mac hotkey inspect install#
We need to install HotKey from the Terminal. Inside that file add the following and save it. Make sure it’s in the base of the project, if you’ve accidentally saved it in the wrong place, make sure to drag it below the GlobalConfigKeybind area with the blue page icon. Then in Xcode, create a new Empty file and call it Cartfile. We’ll use Carthage to install it but If you prefer SPM or CocoaPods feel free to use that instead.įirst, make sure you have Carthage installed, following their installation instructions if needed. HotKey is a Swift package that wraps around the Carbon API for dealing with global hot keys. Click on the Window and in the Attributes inspector change Presentation to Single.Īt this point, if we run the app and press the Preferences button the new window will show.
![mac hotkey inspect mac hotkey inspect](http://allaboutscala.com/wp-content/uploads/2016/06/02_intellij_keyboard_shortcut_compile.png)
Before we test it though, let’s make sure that when the button is pressed more than once it only opens one window. Now when clicked the button will open the Preferences window. Release the mouse and select the Show action segue. The Preferences window will become highlighted. Hold ctrl while click and dragging from the button to the new Preferences window.
![mac hotkey inspect mac hotkey inspect](https://images.macrumors.com/t/BLjRDFMdO0PeOx1kWpC2swZ80QY=/400x0/filters:quality(90)/article-new/2014/10/instanthotspot1.jpg)
Now we have the button but we need to make it do something. Select the button and go to the Attributes inspector. Press the library button, search for Push Button and drag it into the Main view controller. Let’s create a button on the Main view controller and set it up so that when it’s pressed it shows the preferences window. Linking the main app window to the preferences window We can do this by going to Main.storyboard, clicking the Library button, searching for Window View Controller and then drag a new Window Controller next to our Main window. With the app created we need to create the Preferences window. In the second panel, make sure “Use Storyboards” is selected. We need to make sure “MacOS” and “Cocoa App” are selected. This tutorial uses Xcode 10.2 and Swift 5.įirst things first, let’s create a new Mac project in Xcode, I called mine GlobalConfigKeybind.
![mac hotkey inspect mac hotkey inspect](https://wd.imgix.net/image/admin/0bZRHFrsZGxpTAWhYCg6.png)
Set up a simple UI for configuring a global keyboard shortcut that opens your Main window.Installed and configured HotKey via Carthage.
![mac hotkey inspect mac hotkey inspect](https://developer.android.com/studio/images/intro/keymap-options_2-2_2x.png)
Mac hotkey inspect trial#
I recently released my first MacOS app and after a lot of trial and error, discovered that there are not enough Swift for MacOS tutorials! Consider this my first contribution to the cause ?.