Re: How to track a lost mouseDown
Re: How to track a lost mouseDown
- Subject: Re: How to track a lost mouseDown
- From: Steve Cronin <email@hidden>
- Date: Mon, 27 Aug 2007 14:24:41 -0500
Uli;
Thanks for responding!
Yes I noted the cursorRect behavior to support the notion that the
view is instantiated and behaving somewhat as expected.
Yes I have set a breakpoint and an NSLog statement. Neither ever fires.
Yes it is frontmost view.
Here's the header:
@interface MySpecialView : NSView {
}
@end
Here's the implementation:
#import "MySpecialView.h"
@implementation MySpecialView
- (void)awakeFromNib
{
NSLog(@"superV = %@",[self superview]);
NSLog(@"supersuperV = %@",[[self superview] superview]);
}
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (void)resetCursorRects
{
[super resetCursorRects];
NSRect resizeSizeRect = NSMakeRect(NSWidth([self frame]) - 23, 0,
23, 23);
[self addCursorRect:resizeSizeRect cursor:[NSCursor
pointingHandCursor]];
}
- (void)mouseDown:(NSEvent *)event
{
NSLog(@"mouseDown Received");
}
That's it. I never see the log entry for mouseDown no matter where
in the view I click!
If I put other IB widgets in the view (buttons, tableViews, etc) they
all receive and handle clicks correctly.
I'm definitely running in debug mode.
I don't understand your final comments about adding to NSResponder....
Thanks Again for your time!
Steve
On Aug 27, 2007, at 1:23 PM, Uli Kusterer wrote:
On 27.08.2007, at 19:53, Steve Cronin wrote:
My customView's - resetCursorRects gets called and the cursor
changes correctly when mouse moves thru the rect.
So, I guess the view is where you think it should be, good.
However when I then mouseDown (inside the changed cursorRect!) -
nothing
Have you tried setting a breakpoint in your mouseDown method and
running it in the debugger to see whether it's called, or added an
NSLog() call at the start? Maybe it *is* called but your code just
doesn't do what you think it should? If it isn't called, have you
checked your mouseDown method's name, parameters and return value
for correctness? I.e. are they exactly the same as in the
declaration in NSResponder or NSView or wherever they're first
declared?
Can you post your mouseDown method? Can you post the header for
your class? (In particular, what have you chosen as the base class,
and what other methods are you overriding?)
Is your view frontmost?
It's always a good idea to run your code in the debugger and add
NSLog() calls to see where it is failing exactly, (if the debugger
doesn't trigger, always try an NSLog() or NSBeep() -- Sometimes the
debugger just got confused or you're accidentally running a release
build). And when posting here, posting code is always helpful.
To find out where an event is going, you could override sendEvent:
in NSApplication and NSWindow (using method swizzling), and add a
mouseDown method to NSResponder, to detect some places where an
event may go, but I'm not sure there's a way to get informed of
events that get dispatched to other views.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden