|Apr 12, 2011, 12:35 AM||#1|
NSView and subclassing
Is subclassing an nsview my only choice if I want to override the hittest method and also the method that are invoked for mouse events? Is there any other simpler way?
The reason why I am asking this is becuase I have a main super view in whcih i have alot of subviews such as nstextfield and nstextview and nsimageview. I want to know when a mouse if over my main super view but my subviews intercept this and the only way for me to avoid this is to subclass all of them and override hittest method for all of them to direct it to the super view....I can do that but subclassing just for 1 method doesn't seem right to me.
So, i just want to know if that is my only options.
|Apr 12, 2011, 06:18 AM||#2|
What exactly are you trying to do?
For example, if I create a custom NSView subclass, put a NSTextField in it, and override it's hitTest: to always return self when the mouse inside the bounds of the custom NSView, then my custom NSView always gets the mouseDown: event, for example, even if the mouse is over the NSTextField.
BTW NSWindow is in control of dispatching mouse event to an NSView. For hitTest: it starts at the top of the view hierarchy and goes down until either all leafs return nil, or it encounters a view that returns self to hitTest:.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Subclasses and Protected Methods||darkandlong||iPhone/iPad Programming||8||Sep 22, 2011 06:34 AM|
|NSView and NSViewControllers: Loading NIBS inside NSView's?||Yellowstone2012||Mac Programming||2||Jul 9, 2011 07:43 PM|
|Rotate a NSView and make it's origin point starts from the bottom left corner||smokyonion||Mac Programming||2||May 25, 2011 02:33 PM|
|call method from subclass of uiimageview||sregorcinimod||iPhone/iPad Programming||3||Apr 23, 2011 12:54 AM|
|NSView and NSTextField||gomezman78||Mac Programming||1||Dec 24, 2010 06:33 PM|
All times are GMT -5. The time now is 05:14 AM.