Handle copy ss url to pastboard.

This commit is contained in:
Charlie Qiu
2016-06-10 22:33:27 +08:00
parent 1e0a1e8618
commit 9de58d3981
2 changed files with 24 additions and 1 deletions

View File

@ -177,10 +177,13 @@
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6mK-sY-xoH">
<rect key="frame" x="14" y="13" width="291" height="32"/>
<buttonCell key="cell" type="push" title="Copy URL to Clipboard" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="t3T-Kd-5La">
<buttonCell key="cell" type="push" title="Copy URL to Clipboard" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="t3T-Kd-5La">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="copyCurrentProfileURL2Pasteboard:" target="-2" id="DNw-U2-4fD"/>
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="R4F-j7-GkK">
<rect key="frame" x="111" y="211" width="122" height="22"/>

View File

@ -101,6 +101,26 @@ class PreferencesWindowController: NSWindowController
window?.performClose(self)
}
@IBAction func copyCurrentProfileURL2Pasteboard(sender: NSButton) {
let index = profilesTableView.selectedRow
if index >= 0 {
let profile = profileMgr.profiles[index]
let ssURL = profile.URL()
if let url = ssURL {
// Then copy url to pasteboard
// TODO Why it not working?? It's ok in objective-c
let pboard = NSPasteboard.generalPasteboard()
pboard.clearContents()
let rs = pboard.writeObjects([url])
if rs {
NSLog("copy to pasteboard success")
} else {
NSLog("copy to pasteboard failed")
}
}
}
}
func updateProfileBoxVisible() {
if profileMgr.profiles.isEmpty {
profileBox.hidden = true