objective c - how can i copy the text in the textfield cell (in cocoa) to NSPasteboard? -


I have a text button in the textfield cell and cocoa. I want to make a copy of the text in the text text field by clicking on the button.

In the clipboard.

  #import & lt; Cocoa / Cocoa H & gt; @Interfaces clipboard: NSBECES {IBotlet ID but 1; IBOutlet ID numf2_1; NSPasteboard * Pasteboard; } - Write (BOOL) pasteboard: (NSString *) Stringroot; - (NSString *) readFromPasteBoard; - (id) Init; // - (IBAction) insert_cb: (ID) sender; Clipboard @end  

"clipboard .h" // @ implementation clipboard @ Implementation clipboard // - (IBAction) insert_cb: (ID) sender {- (id) Init { [Super Init]; Pasteboard = [nsptboard general pasteboard]; Self return; } - Write (BOOL) Pasteboard: (NSString *) stringTourSiteSite {[Pasteboard declared type: [NSArray arrayWithObject: NSStringPboardType] Owner: Zero]; Return [Pasteboard SetString: Type for StringsOoote: NSStringPboardType]; } - (NSString *) readFromPasteBoard {Return [Pasteboard StringForType: NSStringPboardType]; } @end

How can I do this?

You do not actually write any to yourself: messages, So you need to do that you want to ask for the text field for your string value and that you want to pass as the argument for the writeToPasteboard: message.

Better yet, copy the only of the first reply: the action text field responds to this message, so long as this is the first response (or at least the high North series series ), The action message will hit the field and the field will copy its copy of the text. See for more information.

Similarly, the Copy menu item already works in your main menu, and it is not necessary that you write any code to apply menu items or buttons.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -