Can I add an action to a NSImage which is drawn in a NSTextFieldCell ?
Or should I implement a NSImageView or NSButton for it ? If so, how do I add such view or button to the NSTextFieldCell ?
thanks
Instead of using NSImage,you can use NSButton .Set its image as you are doing for NSImage.Add the selector for that button .
NSButton *objNSButton = [[NSButton alloc] init];
[objNSButton setImage: YourImage];
[objNSButton setTarget:self];
[objNSButton setAction:@selector(buttonAction:)];
[objNSButton drawWithFrame:'SelfDefinedRectForButton' inView:NStextFieldCellObject];
You can also setAlternate image option if you want chagne in image on click of that button.
create a custom Button with UIButtonTypeCustom and then set image by using -setImage function and then add a selector as a target.
You can also refer this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.