1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Merge pull request #516 from TomHarte/MacInsertUI

Adds an 'Insert...' menu option.
This commit is contained in:
Thomas Harte 2018-08-05 22:51:00 -04:00 committed by GitHub
commit 1852786609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -116,6 +116,11 @@
<action selector="saveScreenshot:" target="-1" id="7ky-xD-tip"/>
</connections>
</menuItem>
<menuItem title="Insert..." keyEquivalent="O" id="qQa-kh-4nz">
<connections>
<action selector="insertMedia:" target="-1" id="9Hs-9J-dlY"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="rXU-KX-GkZ"/>
<menuItem title="Page Setup…" enabled="NO" keyEquivalent="P" id="qIS-W8-SiK">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>

View File

@ -213,6 +213,7 @@ class MachineDocument:
}
}
// MARK: Runtime media insertion.
final func openGLView(_ view: CSOpenGLView, didReceiveFileAt URL: URL) {
let mediaSet = CSMediaSet(fileAt: URL)
if let mediaSet = mediaSet {
@ -220,6 +221,20 @@ class MachineDocument:
}
}
@IBAction final func insertMedia(_ sender: AnyObject!) {
let openPanel = NSOpenPanel()
openPanel.beginSheetModal(for: self.windowControllers[0].window!) { (response) in
if response == .OK {
for url in openPanel.urls {
let mediaSet = CSMediaSet(fileAt: url)
if let mediaSet = mediaSet {
mediaSet.apply(to: self.machine)
}
}
}
}
}
// MARK: NSDocument overrides
override func data(ofType typeName: String) throws -> Data {
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)