Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 11, 2011, 11:35 PM   #1
Avicenna
macrumors member
 
Join Date: Jul 2009
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.

Thanks.
Avicenna is offline   0 Reply With Quote
Old Apr 12, 2011, 05:18 AM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
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:.
jiminaus is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Subclassing a subclass - question regarding IBOutlets and IBActions moonman239 iPhone/iPad Programming 1 Sep 27, 2013 08:15 PM
Resolved: Trying to subclass NSView Hans Kamp Mac Programming 9 Mar 25, 2013 04:43 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

Forum Jump

All times are GMT -5. The time now is 09:40 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC