Re: Handling right click only
Re: Handling right click only
- Subject: Re: Handling right click only
- From: Peter Maurer <email@hidden>
- Date: Tue, 14 Dec 2004 13:28:15 +0100
Well, I made a start, but what do I fill in to make the event be
ignored in the else part:
- (void)sendEvent:(NSEvent *)anEvent{
NSEventType type = [anEvent type];
if (type==NSRightMouseDown) || (type==NSLeftMouseDown && ([anEvent
modifierFlags] & NSControlKeyMask)){
} else {
// WHAT HERE TO IGNORE THIS EVENT BY MY APP AND FORWARD THE EVENT TO
THE NEXT APP?
}
}
[super sendEvent: anEvent];
I haven't tested this, but I would assume that the original
implementation (super's -sendEvent:) checks your window's
ignoresMouseEvents attribute. Your method should look like this
(written in Mail.app, all usual disclaimers apply):
- (void)sendEvent: (NSEvent*)theEvent {
NSEventType theEventType = [theEvent type];
if ((theEventType==NSRightMouseDown) ||
((theEventType==NSLeftMouseDown) && ([theEvent modifierFlags] &
NSControlKeyMask))) {
// deal with your right mouse clicks here
return; // eat the event
}
[super sendEvent: theEvent];
}
Cheers,
Peter.
Thanks Severin, but this is not exactly what I need, the question
is, can an event fired to [self nextResponder] end up eventually at
a different application? What I want is all events to be redirected
as if my window wasn't there, except for right mouse clicks:
The situations is as follows (as seen from the side):
**** **** **** finder icons
----------------- my semi transparent CD window
++++++++++ finder desktop
The moment I disable the clickthrough of my window it will start
catching all mouse events away from the finder, even though its
desktop icons are projected above my window....
Alex
Have you tried overriding your NSApp's -sendEvent: method?
Peter.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden