|Apr 11, 2011, 11:35 PM||#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, 05: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|
|Resolved: Trying to subclass NSView||Hans Kamp||Mac Programming||10||Aug 31, 2014 09:39 AM|
|Subclassing a subclass - question regarding IBOutlets and IBActions||moonman239||iPhone/iPad Programming||1||Sep 27, 2013 08:15 PM|
|Objective-C: What is subclassing?||moonman239||Mac Programming||3||Feb 26, 2013 08:08 PM|
|Subclassing UIDocument||nashyo||iPhone/iPad Programming||5||Jul 31, 2012 03:37 AM|
|subclassing UINavigationController||Tex-Twil||iPhone/iPad Programming||4||Jul 21, 2012 12:59 PM|
All times are GMT -5. The time now is 10:03 PM.