Shumais Ul Haq
Shumais Ul Haq

Reputation: 1447

Right mouse click detection in NSTextFieldCell

I am working with a subclass of NSTextFieldCell and am trying to show a context menu when a right mouse click is performed on the NSTextFieldCell subclass.

MouseDown and rightMouseDown do not work only for the objects of the NSTextFieldCell sublclass, for all the other custom sublcasses, such as that of NSButtonCell, everything works fine.

Can someone help out with this problem, please?

Thanks!

Upvotes: 0

Views: 374

Answers (1)

user3673632
user3673632

Reputation: 11

NSCell has a settable -(NSMenu*)menu property which may be used to define the context menu (overloading -menu isNot good enough). An NSCell is associated with an NSControl. The NSControl (in your case an instance of NSTextField) is a super of NSView which has a settable -(NSMenu*)defaultMenu property to define the context menu and responds to -(NSMenu*)menuForEvent: if you want to create the context menu on the fly. NSView is a super of NSResponder which also has a -(NSMenu*)menu property and responds to -(void)rightMouseDown/Dragged/Up:.

Upvotes: 1

Related Questions