Handle copy ss url to pastboard.
This commit is contained in:
@ -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"/>
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user