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 7738543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:17:35+00:00 2026-06-01T08:17:35+00:00

I have this code which draws a Window and NSView, and have set up

  • 0

I have this code which draws a Window and NSView, and have set up tracking to when mouse entered and exits it increases/decreases the size of my window. The problem is when the mouse events are called and the int value of the width and height are increased, the window redraws itself to the new hight and leaves the old one there, how can I remove the old one and just draw the new one? thanks!

- (void)toggleHelpDisplay:(int)value
    {
            // Create helpWindow.
            NSRect mainFrame = [[NSScreen mainScreen] frame];
            NSRect helpFrame = NSZeroRect;
            float width = 90;
            float height = 90;
            helpFrame.origin.x = (mainFrame.size.width - width) / 2.0;
            helpFrame.origin.y = 200.0;
            helpFrame.size.width = width + value;
            helpFrame.size.height = height + value;

            helpWindow = [[BrightnessView windowWithFrame:helpFrame] retain];

            // Configure window.
            [helpWindow setReleasedWhenClosed:YES];
            [helpWindow setHidesOnDeactivate:NO];
            [helpWindow setCanHide:NO];
            [helpWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
            [helpWindow setIgnoresMouseEvents:NO];

            // Configure contentView.
            NSView *contentView = [helpWindow contentView];
            [contentView setWantsLayer:YES];
            CATextLayer *layer = [CATextLayer layer];
            layer.opacity = 0;
            [contentView setLayer:layer];
            CGColorRef bgColor = CGColorCreateGenericGray(0.0, 0.6);
            layer.backgroundColor = bgColor;
            CGColorRelease(bgColor);
            layer.string = (shadyEnabled) ? HELP_TEXT : HELP_TEXT_OFF;
            layer.contentsRect = CGRectMake(0, 0, 1, 1);
            layer.fontSize = 40.0;
            layer.foregroundColor = CGColorGetConstantColor(kCGColorWhite);
            layer.borderColor = CGColorGetConstantColor(kCGColorWhite);
            layer.borderWidth = 4.0;
            layer.cornerRadius = 4.0;
            layer.alignmentMode = kCAAlignmentCenter;

            [window addChildWindow:helpWindow ordered:NSWindowAbove];

            float helpOpacity = (([NSApp isActive] ? 1 : 0));
            [[[helpWindow contentView] layer] setOpacity:helpOpacity];

            //track mouse so that once hovered make larger.

        self.helpView = contentView;
        trackingArea = [[[NSTrackingArea alloc] initWithRect:[self.helpView bounds]
                                                                     options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
                                                                       owner:self
                                                                    userInfo:nil] autorelease];
        [self.helpView addTrackingArea:trackingArea];

    }

    - (void)mouseEntered:(NSEvent *)event;
    {
        NSLog(@"entered");
        [self toggleHelpDisplay:+100];

    }

    - (void)mouseExited:(NSEvent *)event;
    {
        NSLog(@"exited");
        [self toggleHelpDisplay:-100];
    }
  • 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-06-01T08:17:36+00:00Added an answer on June 1, 2026 at 8:17 am

    It looks like you’re recreating your help window every time your mouse enters or exits, when all you want to do is change its frame. Why not use the code you have to create the window once, and in your mouseDown method just change the frame with setFrame:display:

    [helpWindow setFrame:NSMakeRect(helpWindow.frame.origin.x,helpWindow.frame.origin.y,helpWindow.size.width +100,helpWindow.size.height +100) display:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which draws a square on the main window of
I have this code which is called at an onChange event of an function
I have this code which gets WP posts, but it gets all the posts
I have this code (which is way simplified from the real code): public interface
I have this code which compiles and works as expected: class Right {}; class
I have this code which will include template.php file from inside each of these
I have this code which should create a splash image with either no animation
I have this code which is passed to Paypal checkout: <?php foreach ($paypalBasket as
I have this code which can display drop down in div tag of html.
I have this code which I have found from google. It's a adapter for

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.