-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to change the global shortcut
- Loading branch information
Showing
73 changed files
with
3,302 additions
and
1,281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#import <MASShortcut/Shortcut.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="F0s-24-o6u"> | ||
<dependencies> | ||
<deployment identifier="macosx"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--Window Controller--> | ||
<scene sceneID="Qme-Kj-1fk"> | ||
<objects> | ||
<windowController id="F0s-24-o6u" customClass="PreferencesWindowController" customModule="AnyIpsum" customModuleProvider="target" sceneMemberID="viewController"> | ||
<window key="window" title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="fPl-Sy-pn9"> | ||
<windowStyleMask key="styleMask" titled="YES" closable="YES"/> | ||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> | ||
<rect key="contentRect" x="245" y="301" width="480" height="270"/> | ||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/> | ||
<connections> | ||
<outlet property="delegate" destination="F0s-24-o6u" id="vAX-D1-oyh"/> | ||
</connections> | ||
</window> | ||
<connections> | ||
<segue destination="8mW-aE-maF" kind="relationship" relationship="window.shadowedContentViewController" id="7Ye-LO-H0X"/> | ||
</connections> | ||
</windowController> | ||
<customObject id="1R8-GW-ZIk" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
</scene> | ||
<!--Preferences View Controller--> | ||
<scene sceneID="tF7-2X-Utr"> | ||
<objects> | ||
<viewController id="8mW-aE-maF" customClass="PreferencesViewController" customModule="AnyIpsum" customModuleProvider="target" sceneMemberID="viewController"> | ||
<view key="view" id="rzl-CS-CJI"> | ||
<rect key="frame" x="0.0" y="0.0" width="480" height="161"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
<subviews> | ||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fMg-iw-nhe"> | ||
<rect key="frame" x="18" y="123" width="265" height="17"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
<textFieldCell key="cell" lineBreakMode="clipping" title="Record a custom global keyboard shortcut:" id="HgO-Hx-NPi"> | ||
<font key="font" usesAppearanceFont="YES"/> | ||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> | ||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> | ||
</textFieldCell> | ||
</textField> | ||
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="O5d-LP-iVl" customClass="MASShortcutView"> | ||
<rect key="frame" x="289" y="122" width="171" height="19"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
</customView> | ||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OqC-2i-2jS"> | ||
<rect key="frame" x="14" y="87" width="247" height="32"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
<buttonCell key="cell" type="push" title="Use the default keyboard shortcut" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="qpu-r0-XK8"> | ||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> | ||
<font key="font" metaFont="system"/> | ||
</buttonCell> | ||
<connections> | ||
<action selector="useDefault:" target="8mW-aE-maF" id="ih0-Ai-2wX"/> | ||
</connections> | ||
</button> | ||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ca4-8X-Vtv"> | ||
<rect key="frame" x="171" y="20" width="138" height="21"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> | ||
<buttonCell key="cell" type="bevel" title="Visit AnyIpsum on GitHub" bezelStyle="rounded" alignment="center" controlSize="small" imageScaling="proportionallyDown" inset="2" id="qIz-wa-OvL"> | ||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> | ||
<font key="font" metaFont="smallSystem"/> | ||
</buttonCell> | ||
<color key="contentTintColor" name="linkColor" catalog="System" colorSpace="catalog"/> | ||
<connections> | ||
<action selector="visitGitHubRepository:" target="8mW-aE-maF" id="lIo-Pu-avO"/> | ||
</connections> | ||
</button> | ||
</subviews> | ||
</view> | ||
<connections> | ||
<outlet property="shortcutView" destination="O5d-LP-iVl" id="ETL-ul-eyg"/> | ||
</connections> | ||
</viewController> | ||
<customObject id="PqX-Bq-cKA" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="139" y="730.5"/> | ||
</scene> | ||
</scenes> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Cocoa | ||
import MASShortcut | ||
|
||
class PreferencesViewController: NSViewController, NSApplicationDelegate { | ||
|
||
@IBOutlet weak var shortcutView: MASShortcutView! | ||
|
||
let appDelegate = NSApp.delegate as! AppDelegate | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
shortcutView.associatedUserDefaultsKey = ShortcutManager.defaultsKey; | ||
|
||
shortcutView.shortcutValueChange = { (sender) in | ||
MASShortcutMonitor.shared().register(self.shortcutView.shortcutValue, withAction: self.appDelegate.openMenu) | ||
} | ||
} | ||
|
||
// MARK: - Actions | ||
|
||
@IBAction func useDefault(_ sender: Any) { | ||
shortcutView.shortcutValue = ShortcutManager.defaultShortcut | ||
} | ||
|
||
@IBAction func visitGitHubRepository(_ sender: Any) { | ||
let url = URL(string: "https://github.com/jlowgren/AnyIpsum")! | ||
NSWorkspace.shared.open(url) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Cocoa | ||
|
||
class PreferencesWindowController: NSWindowController, NSWindowDelegate { | ||
|
||
override func windowDidLoad() { | ||
super.windowDidLoad() | ||
|
||
self.window?.center() | ||
self.window?.makeKeyAndOrderFront(nil) | ||
NSApp.activate(ignoringOtherApps: true) | ||
} | ||
|
||
func windowShouldClose(_ sender: NSWindow) -> Bool { | ||
self.window?.orderOut(sender) | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Cocoa | ||
import MASShortcut | ||
|
||
struct ShortcutManager { | ||
|
||
static let defaultsKey = "shortcutDefaultsKey" | ||
|
||
static var defaultShortcut: MASShortcut { | ||
// Returns the default shortcut, Ctrl+Cmd+A | ||
let keyCode = UInt(kVK_ANSI_A) | ||
let modifierFlags: NSEvent.ModifierFlags = [NSEvent.ModifierFlags.control, NSEvent.ModifierFlags.command] | ||
return MASShortcut(keyCode: keyCode, modifierFlags: modifierFlags.rawValue) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ platform :osx, '10.14' | |
target 'AnyIpsum' do | ||
use_frameworks! | ||
|
||
pod 'HotKey' | ||
pod 'MASShortcut', '~> 2.3.6' | ||
end |
Oops, something went wrong.