• 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: Highlighting Drag Target
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Highlighting Drag Target


  • Subject: Re: Highlighting Drag Target
  • From: Daniel Todd Currie <email@hidden>
  • Date: Wed, 20 Oct 2004 12:23:04 +0900

The frameRect that you pass to NSFrameRectWithWidth() must be in the window's coordinates. I do something like this in my NSTableView subclass:

[[NSColor selectedTextBackgroundColor] set];
NSRect highlightRect = [self convertRect:[self visibleRect] toView:[[self window] contentView]];
NSFrameRectWithWidth(highlightRect, 2);
[self display];

Yes, you are correct that the width variable defines the width of the border.

-- DTC


On 2004 Oct 20, at 11:57, Dennis Falling wrote:

Hm, I can't get that to work. Maybe I don't understand how to use it, but I'm trying NSFrameRectWithWidth([self frame],3); (with 3 being an arbitrary value). I'm assuming width to define how big you want the border around the frame to be...correct?

-dennis


On Oct 19, 2004, at 9:29 PM, Daniel Todd Currie wrote:

Perhaps "NSFrameRectWithWidth()" will work better?

-- DTC


On 2004 Oct 20, at 10:21, Dennis Falling wrote:

That doesn't work. You're replacing the context with the saved one immediately after changing it.

Anybody have any ideas?

-dennis


On Oct 18, 2004, at 7:53 AM, Clark Cox wrote:

On Sun, 17 Oct 2004 22:35:26 -0500, Dennis Falling <email@hidden> wrote:
Hi all,

I'm using the following code to highlight an NSImageView subclass when
files are dragged across it:

- (void)drawRect:(NSRect)rect
{
NSBezierPath *path = [NSBezierPath bezierPathWithRect:[self frame]];
if (highlighted)
{
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle(NSFocusRingOnly);
[path fill];
}
else
{
[path closePath];
[NSGraphicsContext restoreGraphicsState];
}
[super drawRect:rect];
}

I originally was subclassing NSView and using the same method (minus
the call to super's drawRect) and it was working fine. But when I
changed over to using the NSImageView, I had to add this call in to
keep the image and border of the view from disappearing.

The problem I'm having is that the bezier path is being draw for
everything in the frame..the border, the image, etc. How can I set it
to just draw it around the inside of the border? In case I'm not being
clear, here's an image of the problem I'm having:
<http://www.csc.tntech.edu/~dsfallin/FasTarIssue.jpg>

How about something more like:

- (void)drawRect:(NSRect)rect
{
if (highlighted)
{
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle(NSFocusRingOnly);
[[NSBezierPath bezierPathWithRect:[self frame]] fill];
[NSGraphicsContext restoreGraphicsState];
}
[super drawRect:rect];
}

--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Highlighting Drag Target
      • From: Dennis Falling <email@hidden>
References: 
 >Highlighting Drag Target (From: Dennis Falling <email@hidden>)
 >Re: Highlighting Drag Target (From: Clark Cox <email@hidden>)
 >Re: Highlighting Drag Target (From: Dennis Falling <email@hidden>)
 >Re: Highlighting Drag Target (From: Daniel Todd Currie <email@hidden>)

  • Prev by Date: Re: application:openFile: usage
  • Next by Date: Re: KVO and accessors - are they needed
  • Previous by thread: Re: Highlighting Drag Target
  • Next by thread: Re: Highlighting Drag Target
  • Index(es):
    • Date
    • Thread