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

  • Home
  • SEARCH
  • 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 549837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:13:31+00:00 2026-05-13T11:13:31+00:00

Hullo all – I’ve got a NSView subclass that I move programmatically on mouseDown.

  • 0

Hullo all – I’ve got a NSView subclass that I move programmatically on mouseDown. Which works, but has an odd side effect:

  1. I click the subview. The subview moves away [GOOD]
  2. I wait a while. I do not move my mouse. Since the subview has moved it’s no longer under my cursor.
  3. I click my mouse again.
    • I expect the underlying window to get the mouseDown event (since the subview is no longer under my cursor), however my subview somehow gets this event [ODD]
    • The mouseDown event clearly shows that the click was outside the bounds of my subclass [ODD]
    • The mouseDown event also clearly shows that the click count has incremented, even though I’ve waited several seconds between mouse clicks [ODD]

… there’s gotta be an explanation for what I’m seeing. Here’s my code – simply create a new Cocoa Application project called “OddMouse”, and copy the following into the OddMouseAppDelegate.h file:

#import <Cocoa/Cocoa.h>
@interface OddMouseAppDelegate : NSObject <NSApplicationDelegate> {
  NSWindow *window;
}
@property (assign) IBOutlet NSWindow *window;
@end

@interface OddView : NSView {
}
@end

… and the following into the OddMouseAppDelegate.m file:

#import "OddMouseAppDelegate.h"
@implementation OddMouseAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

[[window contentView] addSubview:[[OddView alloc] init]];
}
@end

@implementation OddView
- (id)init {
  self = [super initWithFrame:NSMakeRect(100, 100, 100, 100)];
  return self;
}
- (void)drawRect:(NSRect)dirtyRect {
  NSBezierPath *bz = [NSBezierPath bezierPathWithRoundedRect:[self bounds] 
                                                 xRadius:9 yRadius:9];
  [[NSColor blueColor] set];
[bz fill];
}
- (void)mouseDown:(NSEvent *)event {
  NSPoint locationInMyself = [self convertPoint: [event locationInWindow] 
                                       fromView: nil];
  NSLog(@"MOUSE DOWN COORDS: x=%f y=%f, count=%i", 
          locationInMyself.x, locationInMyself.y, [event clickCount]);
  float newX = [self frame].origin.x+100;
  float newY = [self frame].origin.y+100;
  [self setFrame:NSMakeRect(newX, newY, 100, 100)];
}
@end

… then build, then run, then witness ! FWIW, here’s what I see in the console:

10-01-15 11:38:24 PM OddMouse[4583] MOUSE DOWN COORDS: x=48.000000 y=56.000000, count=1
10-01-15 11:38:37 PM OddMouse[4583] MOUSE DOWN COORDS: x=-52.000000 y=-44.000000, count=2
10-01-15 11:38:44 PM OddMouse[4583] MOUSE DOWN COORDS: x=-152.000000 y=-144.000000, count=3
10-01-15 11:38:52 PM OddMouse[4583] MOUSE DOWN COORDS: x=-252.000000 y=-244.000000, count=4
10-01-15 11:39:03 PM OddMouse[4583] MOUSE DOWN COORDS: x=-352.000000 y=-344.000000, count=5
  • 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-13T11:13:31+00:00Added an answer on May 13, 2026 at 11:13 am

    Freaking heck – turns out this was something misbehaving with the double-click speed – changing the prefs did SFA, but a reboot resolved …

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

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer whether or not I should wrap every for loop... No,… May 13, 2026 at 5:54 pm
  • Editorial Team
    Editorial Team added an answer The way to get it to work with an ASMX… May 13, 2026 at 5:54 pm
  • Editorial Team
    Editorial Team added an answer There's a list of differences that claims to be complete… May 13, 2026 at 5:54 pm

Related Questions

Hullo all, Wondering if there are any Java hackers who can clue me in
Hullo to all! This question is more about a shortcut than anything: Is there
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
Hello all and thanks for your time reading this. I need to verify certificates
hello all i am new to iphone development i am working on a application

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.