• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSView and backgrounds, selectable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView and backgrounds, selectable


  • Subject: Re: NSView and backgrounds, selectable
  • From: Matt Jaffa <email@hidden>
  • Date: Tue, 4 May 2004 17:09:27 -0600

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.
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSView and backgrounds, selectable
      • From: Shawn Erickson <email@hidden>
    • Re: NSView and backgrounds, selectable
      • From: Yann Bizeul <email@hidden>
References: 
 >NSView and backgrounds, selectable (From: "Matthew Jaffa" <email@hidden>)
 >Re: NSView and backgrounds, selectable (From: Yann Bizeul <email@hidden>)

  • Prev by Date: Re: setHidden: on MacOS 10.2
  • Next by Date: NSAlert Examples?
  • Previous by thread: Re: NSView and backgrounds, selectable
  • Next by thread: Re: NSView and backgrounds, selectable
  • Index(es):
    • Date
    • Thread