Add a 'Copy' context menu to the QRCode window.

This commit is contained in:
Charlie Qiu
2017-01-12 11:58:57 +08:00
parent 1388c065c7
commit 62648d02f1
3 changed files with 26 additions and 3 deletions

View File

@ -14,4 +14,6 @@
@property (nonatomic, copy) NSString *qrCode;
@property (nonatomic, weak) NSImageView *imageView;
- (IBAction) copyQRCode: (id) sender;
@end

View File

@ -71,4 +71,11 @@
return scaledImage;
}
- (IBAction) copyQRCode: (id) sender{
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
[pasteboard clearContents];
NSArray *copiedObjects = [NSArray arrayWithObject: self.imageView.image];
[pasteboard writeObjects:copiedObjects];
}
@end

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SWBQRCodeWindowController">
@ -16,7 +17,7 @@
<window title="QR Code" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="566" y="456" width="250" height="250"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="250" height="250"/>
<autoresizingMask key="autoresizingMask"/>
@ -25,9 +26,22 @@
<rect key="frame" x="0.0" y="0.0" width="250" height="250"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="iAJ-tw-LNU"/>
<connections>
<outlet property="menu" destination="5h4-gO-Rh7" id="Ps3-TP-31Y"/>
</connections>
</imageView>
</subviews>
</view>
</window>
<menu id="5h4-gO-Rh7">
<items>
<menuItem title="Copy QRCode" id="m8q-W6-UjX">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="copyQRCode:" target="-2" id="vD4-PS-09w"/>
</connections>
</menuItem>
</items>
</menu>
</objects>
</document>