• 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: Scrolling with colorWithPatternImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scrolling with colorWithPatternImage


  • Subject: Re: Scrolling with colorWithPatternImage
  • From: "VividVisions, Walter Krivanek" <email@hidden>
  • Date: Tue, 12 Oct 2004 12:41:46 +0200

Hi,

no, it's not flipped. Otherwise, the dragging wouldn't work the way it does. The scrolling itself works perfectly, but I don't understand, why the patternImage is also moving within the rect.

Actually, the problem appears only during horizontally scrolling. Vertically scrolling does work.

(BTW: I'm working with 10.3.5 and xCode 1.5)

Best,
Walter

Eric Ocean wrote:

It may be that your view is flipped. Try calling -isFlipped in your drawRect: method; if it's flipped, you'll need to change your repositioning logic in -mouseDragged:.

Regards,

Eric Ocean

On Oct 12, 2004, at 2:10 AM, VividVisions, Walter Krivanek wrote:

Hello,

I'm new to this list and unfortunately, the archives can't be searched at the moment. So I don't know if this question has been already asked and answered.

I've got a custom view within a NSScrollView. The only way to scroll should be by dragging the custom view to the new position. And I want to draw some NSRects with a colorWithPatternImage-NSColor on this custom view. This works very well, but the problem is: When I drag the view, the patternImage is scrolling to the opposite direction instead of being bound to its rect.

It's hard to explain. When I drag the view to the right, the rect also goes to the right, but its patternImage scrolls to the left.
It seems that this is a bug in the framework or have I missed something?

The funny thing: When I scroll the view with the scrollBars, this doesn't happen.

Do you know a soution/workaround?

Here is a part of the code of the custom view:

- (void)drawRect:(NSRect)rect
{
// Black background
[[NSColor blackColor] set];
[NSBezierPath fillRect: [self visibleRect]];

// Draw Rect with pattern image
[[NSColor colorWithPatternImage:theImage] set];
[NSBezierPath fillRect: theRect];
[[NSColor greenColor] set];
[NSBezierPath strokeRect: theRect];
}

- (void) mouseDragged: (NSEvent *) event
{
NSRect rect = [self visibleRect];
NSPoint origin = rect.origin;

// Doesn't work
// [self scrollRectToVisible:NSMakeRect(rect.origin.x - [event deltaX], rect.origin.y + [event deltaY], rect.size.width, rect.size.height)];

// Doesn't work either
[self scrollPoint: NSMakePoint(origin.x - [event deltaX], origin.y + [event deltaY])];

[self setNeedsDisplay:YES];
}

Thanks for your help!
Walter

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

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
References: 
 >Scrolling with colorWithPatternImage (From: "VividVisions, Walter Krivanek" <email@hidden>)

  • Prev by Date: Re: NSArrayController and the ContentArray Binding
  • Next by Date: Re: NSMatrix made of custom buttons?
  • Previous by thread: Scrolling with colorWithPatternImage
  • Next by thread: Cocoa OpenGL and text
  • Index(es):
    • Date
    • Thread