Learning Cocoa (some random thoughts) : Subclassing NSTextView :
Created a custom NSTexView, and wanted to provide a placeholder string which will disappear when the user starts typing.
Thought overriding
-(void)mouseDown:(NSEvent*)event ,
and
-(void)keyDown:(NSEvent*)event
will be sufficient.
But, when this custom textview is the first responder of events(i.e. in focus when the nib loads), pasting/drag-drop on this textview did not clear the placeholder string.
After some more search(thanks to mac dev library and Jeremy), found out that I had to override :
- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard type:(NSString *)type
This helped in detecting the paste events/operation on my custom textview component. And voilĂ my custom NSTextView now works amazing.
- Ciao.
Created a custom NSTexView, and wanted to provide a placeholder string which will disappear when the user starts typing.
Thought overriding
-(void)mouseDown:(NSEvent*)event ,
and
-(void)keyDown:(NSEvent*)event
will be sufficient.
But, when this custom textview is the first responder of events(i.e. in focus when the nib loads), pasting/drag-drop on this textview did not clear the placeholder string.
After some more search(thanks to mac dev library and Jeremy), found out that I had to override :
- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard type:(NSString *)type
This helped in detecting the paste events/operation on my custom textview component. And voilĂ my custom NSTextView now works amazing.
- Ciao.
No comments:
Post a Comment