Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Cocoa/Cocoa.h>
- @interface EditTextField : NSTextField <NSTextDelegate>
- @end
- ---
- #import "EditTextField.h"
- @implementation EditTextField
- - (void) mouseDown:(NSEvent *)theEvent {
- if(theEvent.clickCount == 2) {
- self.editable = TRUE;
- NSText * fieldEditor = [self.window fieldEditor:TRUE forObject:self];
- [self.cell editWithFrame:self.bounds inView:self editor:fieldEditor delegate:self event:theEvent];
- } else {
- [super mouseDown:theEvent];
- }
- }
- - (void) cancelOperation:(id)sender { //cancel key triggers cancelOperation on firstResponder.
- NSText * fieldEditor = [self.window fieldEditor:TRUE forObject:self];
- [self.cell endEditing:fieldEditor];
- self.editable = FALSE;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment