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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:23:09+00:00 2026-05-14T18:23:09+00:00

I’m trying to re-write an application I have for Windows in Objective-C for my

  • 0

I’m trying to re-write an application I have for Windows in Objective-C for my Mac, and I want to be able to do something like Mac’s hot corners. If I move my mouse to the left side of the screen it will make a window visible, if I move it outside of the window location the window will hide again. (window would be pushed up to the left side of screen).

Does anyone know where I can find some demo code (or reference) on how to do this, or at least how to tell where the mouse is at, even if the current application is not on top. (not sure how to word this, too used to Windows world).

Thank you

-Brad

  • 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-14T18:23:10+00:00Added an answer on May 14, 2026 at 6:23 pm

    Here’s what I came up with. Thanks to Peter for the above tips.

       @interface SlidingWindow : NSWindow
        {
            CGRectEdge _slidingEdge;
            NSView *_wrapperView;
        }
    
    
        @property (nonatomic, assign) CGRectEdge slidingEdge;
        @property (nonatomic, retain) NSView *wrapperView;
    
        -(id)initWithContentRect:(NSRect) contentRect 
                       styleMask:(unsigned int) styleMask 
                         backing:(NSBackingStoreType) backingType 
                           defer:(BOOL) flag;
    
        - (NSView*)wrapperViewWithFrame:(NSRect)bounds;
    
        - (BOOL)mayOrderOut;
    
        @end
    
        @interface SlidingWindow ()
    
        - (void)adjustWrapperView;
    
        - (void)setWindowWidth:(NSNumber*)width;
        - (void)setWindowHeight:(NSNumber*)height;
    
        @end
    
    
        @implementation SlidingWindow
    
    
    @synthesize slidingEdge = _slidingEdge;
    @synthesize wrapperView = _wrapperView;
    
    
    - (id)initWithContentRect:(NSRect) contentRect 
                    styleMask:(unsigned int) styleMask 
                      backing:(NSBackingStoreType) backingType 
                        defer:(BOOL) flag
    {
    
        if ((self = [super initWithContentRect:contentRect
                                     styleMask:NSBorderlessWindowMask 
                                       backing:backingType
                                         defer:flag])) {
            /* May want to setup some other options, 
             like transparent background or something */
    
            [self setSlidingEdge:CGRectMaxYEdge];
            [self setHidesOnDeactivate:YES];
            [self setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
        }
    
        return self;
    }
    
    - (NSView*)wrapperViewWithFrame:(NSRect)bounds
    {
        return [[[NSView alloc] initWithFrame:bounds] autorelease];
    }
    
    - (void)adjustWrapperView
    {
        if (self.wrapperView == nil) {
            NSRect frame = [self frame];
            NSRect bounds = NSMakeRect(0, 0, frame.size.width, frame.size.height);
            NSView *wrapperView = [self wrapperViewWithFrame:bounds];
            NSArray *subviews =  [[[[self contentView] subviews] copy] autorelease];
    
            for (NSView *view in subviews) {
                [wrapperView addSubview:view];
            }
    
            [wrapperView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
            [[self contentView] addSubview:wrapperView];
    
            self.wrapperView = wrapperView;
        }
    
        switch (self.slidingEdge) {
            case CGRectMaxXEdge:
                [self.wrapperView setAutoresizingMask:(NSViewHeightSizable | NSViewMaxXMargin)];
                break;
    
            case CGRectMaxYEdge:
                [self.wrapperView setAutoresizingMask:(NSViewWidthSizable | NSViewMaxYMargin)];
                break;
    
            case CGRectMinXEdge:
                [self.wrapperView setAutoresizingMask:(NSViewHeightSizable | NSViewMinXMargin)];
                break;
    
            case CGRectMinYEdge:
            default:
                [self.wrapperView setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
        }
    }
    
    - (void)makeKeyAndOrderFront:(id)sender
    {
        [self adjustWrapperView];
    
        if ([self isVisible]) {
            [super makeKeyAndOrderFront:sender];
        }
        else {
            NSRect screenRect = [[NSScreen menubarScreen] visibleFrame];
            NSRect windowRect = [self frame];
    
            CGFloat x;
            CGFloat y;
            NSRect startWindowRect;
            NSRect endWindowRect;
    
            switch (self.slidingEdge) {
                case CGRectMinXEdge:
                    x = 0;
                    y = (screenRect.size.height - windowRect.size.height) / 2 + screenRect.origin.y;
                    startWindowRect = NSMakeRect(x - windowRect.size.width, y, 0, windowRect.size.height);
                    break;
    
                case CGRectMinYEdge:
                    x = (screenRect.size.width - windowRect.size.width) / 2 + screenRect.origin.x;
                    y = 0;
                    startWindowRect = NSMakeRect(x, y - windowRect.size.height, windowRect.size.width, 0);
                    break;
    
                case CGRectMaxXEdge:
                    x = screenRect.size.width - windowRect.size.width + screenRect.origin.x;
                    y = (screenRect.size.height - windowRect.size.height) / 2 + screenRect.origin.y;
                    startWindowRect = NSMakeRect(x + windowRect.size.width, y, 0, windowRect.size.height);
                    break;
    
                case CGRectMaxYEdge:
                default:
                    x = (screenRect.size.width - windowRect.size.width) / 2 + screenRect.origin.x;
                    y = screenRect.size.height - windowRect.size.height + screenRect.origin.y;
                    startWindowRect = NSMakeRect(x, y + windowRect.size.height, windowRect.size.width, 0);
            }
    
            endWindowRect = NSMakeRect(x, y, windowRect.size.width, windowRect.size.height);
    
            [self setFrame:startWindowRect display:NO animate:NO];
    
            [super makeKeyAndOrderFront:sender];
    
            [self setFrame:endWindowRect display:YES animate:YES];
    
            [self performSelector:@selector(makeResizable)
                       withObject:nil
                       afterDelay:1];
        }
    }
    
    - (void)makeResizable
    {
        NSView *wrapperView = self.wrapperView;
        NSRect frame = [self frame];
        NSRect bounds = NSMakeRect(0, 0, frame.size.width, frame.size.height);
    
        [wrapperView setFrame:bounds];
        [wrapperView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
    }
    
    - (void)orderOut:(id)sender
    {
        [self adjustWrapperView];
    
        NSRect startWindowRect = [self frame];
        NSRect endWindowRect;
    
        switch (self.slidingEdge) {
            case CGRectMinXEdge:
                endWindowRect = NSMakeRect(startWindowRect.origin.x, 
                                           startWindowRect.origin.y,
                                           0,
                                           startWindowRect.size.height);
                break;
    
            case CGRectMinYEdge:
                endWindowRect = NSMakeRect(startWindowRect.origin.x, 
                                           startWindowRect.origin.y, 
                                           startWindowRect.size.width, 
                                           0);
                break;
    
            case CGRectMaxXEdge:
                endWindowRect = NSMakeRect(startWindowRect.origin.x + startWindowRect.size.width, 
                                           startWindowRect.origin.y,
                                           0,
                                           startWindowRect.size.height);
                break;
    
            case CGRectMaxYEdge:
            default:
                endWindowRect = NSMakeRect(startWindowRect.origin.x, 
                                           startWindowRect.origin.y + startWindowRect.size.height, 
                                           startWindowRect.size.width, 
                                           0);
        }
    
        [self setFrame:endWindowRect display:YES animate:YES];
    
        switch (self.slidingEdge) {
            case CGRectMaxXEdge:
            case CGRectMinXEdge:
                if (startWindowRect.size.width > 0) {
                    [self performSelector:@selector(setWindowWidth:)
                               withObject:[NSNumber numberWithDouble:startWindowRect.size.width]
                               afterDelay:0];
                }
                break;
    
            case CGRectMaxYEdge:
            case CGRectMinYEdge:
            default:
                if (startWindowRect.size.height > 0) {
                    [self performSelector:@selector(setWindowHeight:)
                               withObject:[NSNumber numberWithDouble:startWindowRect.size.height]
                               afterDelay:0];
                }
        }
    
        [super orderOut:sender];
    }
    
    - (void)setWindowWidth:(NSNumber*)width
    {
        NSRect startWindowRect = [self frame];
        NSRect endWindowRect = NSMakeRect(startWindowRect.origin.x, 
                                          startWindowRect.origin.y, 
                                          [width doubleValue],
                                          startWindowRect.size.height);
    
        [self setFrame:endWindowRect display:NO animate:NO];    
    }
    
    - (void)setWindowHeight:(NSNumber*)height
    {
        NSRect startWindowRect = [self frame];
        NSRect endWindowRect = NSMakeRect(startWindowRect.origin.x, 
                                          startWindowRect.origin.y, 
                                          startWindowRect.size.width, 
                                          [height doubleValue]);
    
        [self setFrame:endWindowRect display:NO animate:NO];    
    }
    
    - (void)resignKeyWindow
    {
        [self orderOut:self];
    
        [super resignKeyWindow];
    }
    
    - (BOOL)canBecomeKeyWindow
    {
        return YES;
    }
    
    - (void)performClose:(id)sender
    {
        [self close];
    }
    
    - (void)dealloc
    {
        [_wrapperView release], _wrapperView = nil;
    
        [super dealloc];
    }
    
    @end
    
    
    @implementation NSScreen (MenubarScreen)
    
    + (NSScreen*)menubarScreen
    {
        NSArray *screens = [self screens];
    
        if ([screens count] > 0) {
            return [screens objectAtIndex:0];
        }
    
        return nil;
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.