Re: NSView and backgrounds, selectable
Re: NSView and backgrounds, selectable
- Subject: Re: NSView and backgrounds, selectable
- From: Matt Jaffa <email@hidden>
- Date: Tue, 11 May 2004 16:05:20 -0600
I got it now,
I just decided to make my view a subclass of NSScrollView,
and used the setBackgroundColor method to accomplish my purposes.
Matt
On May 11, 2004, at 3:18 PM, Yann Bizeul wrote:
That's because
-(void)drawRect:(NSRect)aRect
is special, you need to draw everything inside, or at least call
functions to draw inside. It is called by the system at the right time
when the view need to be refreshed.
Have fun :-)
Le 5 mai 04, ` 01:09, Matt Jaffa a icrit :
Hey,
yeah you have the gist of what I am trying to do.
The color is properly being made in the views,
but after it has been select how then do I change the color and have
it draw it again,
but it is not working the way I did it, I made a method
setBackGroundColor:(NSColor*)theColor
{
NSBezierPath *surface = [ NSBezierPath bezierPathWithRect: [ self
bounds ]];
[[ NSColor redColor ] set ];
[ surface fill ];
[ super drawRect: [self visibleRect] ];
}
This seems to not be working, but I probably am a little lost,
help would be appreciated,
Thanks,
Matt
On May 4, 2004, at 5:57 AM, Yann Bizeul wrote:
I was wondering if there was a way to set NSView's background to a
different color,
I know that NSTableView wrapped in a ScrollView, has this
capability.
You can try to draw things in drawRect: method, like this (from
memory)
-(void)drawRect:(NSRect)aRect
{
NSBezierPath *surface = [ NSBezierPath bezierPathWithRect: [ self
bounds ]];
[[ NSColor redColor ] set ];
[ surface fill ];
[ super drawRect: aRect ];
}
And also what is the way to make a NSView Selectable?
Catch mouseDown events (see NSResponder documentation) and change the
color, or contour like above
Here is my scenario, I have a NSSplitView that is a subview of a
NSScrollView, And I am adding custom NSSplitViews to that
NSPlitView,
So I want the added NSSplitViews to be able to be selectable and
have
a different color of background.
Any way to set the NSScrollView's color and make them selectable?
Let me re-formulate :
You have a NSScrollView, that contains a NSSplitView, with multiple
NSView's inside ? And you want them to be selectable ?
Am I right ?
I would try to subclass NSSplitView to add an instance variable
holding
the current selection.
This way, each subview would be able to send a [[ self superview ]
setSelection: self ]; so that your NSSplitView would be able to
notify
the old selection to return to a normal background.
If somebody has a better idea... :-)
--
Yann Bizeul - yann at tynsoe.org
http://projects.tynsoe.org/
_______________________________________________
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.
--
Yann Bizeul - yann at tynsoe.org
http://projects.tynsoe.org/
_______________________________________________
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.