Fwd: Re: Displaying my view in a Window
Fwd: Re: Displaying my view in a Window
- Subject: Fwd: Re: Displaying my view in a Window
- From: Chaffinch <email@hidden>
- Date: Tue, 11 Feb 2003 16:41:37 +0000 (GMT)
--- Gerard Iglesias <email@hidden> wrote: > Date: Tue, 11 Feb
2003 15:36:20 +0100
>
From: Gerard Iglesias <email@hidden>
>
To: Chaffinch <email@hidden>
>
Subject: Re: Displaying my view in a Window
>
>
Hi,
>
>
>
>In Interface Builder I have a created an NSScrollView as a custom view in
>
my
>
>main window. I have defined an IBOutlet that connect to this NSScrollView.
>
>
>
What do you mean here ?
>
>
Did you drag a custom view widget from the palette to the window and
>
then said that it is a NSScrollView with the help of the 'Custom Class'
>
inspector ?
>
>
If this is the case, then you get a not configurated scroll view after
>
the nib has been unarchived.
>
>
>In my code I have sub-classed NSWindowController. In this sub-class I
>
>programmatically create a text view for placing in the NSScrollView
>
created
>
>with IB.
>
>
>
You can do the same without creating the scroll view as a custom view,
>
create a real scroll view by drag and drop in IB, and then in you code
>
replace the document view owith you own created NSTextView
>
>
>The problem is getting the actual text view to display, I originally tried
>
>the following in the window controllers awakeFromNib:
>
>
>
> [ scrollView setDocumentView:textView ];
>
> [ window setContentView:scrollView ];
>
> [ window makeKeyAndOrderFront:nil ];
>
> [ window makeFirstResponder:textView ];
>
>
>
What happened exactly.
>
>
>But what this actually seems to do is cover the whole of my window, and
>
not
>
>end up within the borders of the NSScrollView I created in IB.
>
>
>
>
Seems to be due to your scroll view is not configured properly, and has
>
no scroll bar....
>
>
>Reading the
>
>documentation last night, am I correct in thinking that the Content View
>
is
>
>not written to directly but "contains" various NSViews which are written
>
>into. So do I need to actually use addSubView here instead of
>
>setContentView??
>
>
>
>Further, if I define NSWindow * theWindow; in my window controllers header
>
>file and then change the above code to:
>
>
>
> [ scrollView setDocumentView:textView ];
>
> [ theWindow setContentView:scrollView ];
>
> [ theWindow makeKeyAndOrderFront:nil ];
>
> [ theWindow makeFirstResponder:textView ];
>
>
>
>everything seems to work as I would like. But, I never alloc or init
>
>theWindow and never connect it to anything in IB. Why does this work? I am
>
>sure this can't be correct
>
>
>
It can't be correct, your theWindow outlet need to be connected, but it
>
is not necessary, because if you are working on a document based
>
application the window outlet of the NSWindowController class is already
>
connected...
>
>
Gerard
>
>
=====
Regards
Chaffinch
----------------------------------------------
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.