Skip navigation.
 
mlRe: Overlapping Views
FROM : Ricky Sharp
DATE : Fri Nov 23 18:16:11 2007

On Nov 23, 2007, at 11:03 AM, David Alger wrote:

>
> On Nov 23, 2007, at 10:01 AM, Alastair Houghton wrote:
>

>> On 23 Nov 2007, at 07:09, Jon Hess wrote:
>>

>>> NSView fully supports overlapping sibling views on Leopard and 
>>> later.

>>
>> I know it's been a common request for ages on the list, but I've 
>> never quite been sure why people are so keen on being able to have 
>> overlapping sibling views.  If one is completely contained within 
>> the other, the parent-child relationship seems cleaner (and has 
>> always worked); and if that isn't possible then surely in most 
>> cases it's going to look ugly?
>>
>> So, out of interest, David, what were you trying to achieve that 
>> needed overlapping views?

>
> This particular app would be a full-screen app. The main window, 
> covering most if not all of the screen, would have a background 
> image with other controls directly on top of it. They would be 
> customized to the extent I could in IB & sub-classed if necessary, 
> which I know that I will have to do to achieve the behavior & 
> appearance I want in some. Since the NSImage view doesn't support 
> sub-views (I'm assuming it doesn't since IB won't let me put any in 
> it), I was trying to have the NSImage view behind the other views so 
> I wouldn't have to customize a NSView & draw the image manually.
>
> This will be my very first app written in Cocoa/Obj-C, and I'm very 
> used to having compositing views in Carbon. I won't be overlapping 
> views like this though if it isn't really supported, since I don't 
> want my app to possibly have erratic drawing/refresh behavior.


In this specific case, it is trivial to do what you want with subviews.

Drag in a custom view which will serve as your background view.  IB 
knows that custom views are contain views and thus you can put 
anything you want inside.  Subclass NSView and specify that class for 
your custom view.  It's drawRect: will draw whatever image you want.

Building upon that, you could always put your NSView subclass into an 
IB Plug-In (if using IB 3.x) or a palette (IB 2.x).  That's the 
approach I went with.  I thus had a container view with a single 
'background image' attribute that I could set at design time within 
IB.  IB also displayed the selected image to include when running 
under the simulator.

___________________________________________________________
Ricky A. Sharp        mailto:<email_removed>
Instant Interactive(tm)  http://www.instantinteractive.com

Related mailsAuthorDate
mlOverlapping Views David Alger Nov 23, 04:49
mlRe: Overlapping Views Ricky Sharp Nov 23, 05:02
mlRe: Overlapping Views Jon Hess Nov 23, 08:09
mlRe: Overlapping Views Scott Anguish Nov 23, 09:06
mlRe: Overlapping Views David Alger Nov 23, 14:22
mlRe: Overlapping Views Ricky Sharp Nov 23, 14:27
mlRe: Overlapping Views Alastair Houghton Nov 23, 17:01
mlRe: Overlapping Views David Alger Nov 23, 18:03
mlRe: Overlapping Views Ricky Sharp Nov 23, 18:16
mlRe: Overlapping Views Alastair Houghton Nov 23, 18:16
mlRe: Overlapping Views Jean-Daniel Dupas Nov 23, 18:16
mlRe: Overlapping Views David Alger Nov 23, 18:40
mlRe: Overlapping Views Jon Hess Nov 24, 06:06
mlRe: Overlapping Views Scott Anguish Nov 24, 08:40
mlRe: Overlapping Views Uli Kusterer Nov 24, 11:25
mlRe: Overlapping Views Uli Kusterer Nov 24, 11:29
mlRe: Overlapping Views Scott Anguish Nov 24, 23:47
mlRe: Overlapping Views Uli Kusterer Nov 26, 09:57