Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7247891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:03:58+00:00 2026-05-28T22:03:58+00:00

I’m drawing rectangles on the screen using the basic NSBezierPath method. I have an

  • 0

I’m drawing rectangles on the screen using the basic NSBezierPath method. I have an object set up to draw a customized rectangle on the screen with each instance of the object initialized. In that object I have a method that moves the rectangle around with the mouse when its dragged across the screen. To accomplish this I simply used the mouseDragged: method. The problem is as I move it, it leaves behind “image artifacts” which appear as thin 1px lines on the screen along the edges of where the rectangle was previously. This is similar to how when Microsoft Windows was running slowly, it used to leave ghosts of a window as you dragged it around. Remember how you would always try to draw stuff or fill the entire screen before it unfroze? Its like its just not redrawing quickly enough or something. The artifacts never go away unless I clear them out by drawing something over them (like dragging the rectangle back over them).

-(void)mouseDown:(NSEvent *)theEvent{
mouseLoc = [theEvent locationInWindow];
xDifference = mouseLoc.x - origin.x;
yDifference = mouseLoc.y - origin.y;

}

-(void)mouseDragged:(NSEvent *)theEvent{
mouseLoc = [theEvent locationInWindow];
NSPoint adjustedOrigin = NSMakePoint((mouseLoc.x-xDifference), (mouseLoc.y-yDifference));
[self setOrigin:adjustedOrigin];


}

Also if you’re wondering about the blank square to the left of the blue rectangle, I can’t explain it either. I have the black ‘rhombus’ going around in circles 30px in diameter, but every time it moves one space (one a second on an NSTimer) it jumps very briefly to that spot, but why I have no clue. the code for the movement of the rectangle is below:

i+=.5;
int rectangle2X = (100+30*cos(i));
int rectangle2Y = (100+30*sin(i));
//NSLog(@"(%d, %d)", rectangle2X, rectangle2Y);
rectangle2.origin = NSMakePoint(rectangle2X, rectangle2Y);

Any help would be great. I know the code above isn’t everything that you guys might need so feel free to ask for more. The top code is from the object, the bottom code comes from the AppDelegate. Both rectangles in the picture are instances of my object.

Picture of Artifacts

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:03:59+00:00Added an answer on May 28, 2026 at 10:03 pm

    Don’t worry just call it modern art!

    But seriously. It looks like you are not clearing the view in the drawRect: or drawInContext: method.

    Paint a rect of background color over the bounds as the first thing you do to clear the prior drawing.

    [myBGColor set];
    NSRectFill([self bounds]);
    

    NSViews don’t automatically clear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.