Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling right click only



Hi Peter,

Unfortunately that doesn't work. The moment I set the window to ignore the mouse events, the app won't even be called, so the sendEvent method is not executed. If I let the window get the mouse events, I nicely see it run the code below, unfortunately the [super sendEvent: theEvent]; doesn't relay the event to the window/app below. Somehow I think I have to refire the event, such that I won't get it this time... I also tried [[self nextResponder] sendEvent: theEvent], but that doesn't help either...
Alex




Op 14-dec-04 om 13:26 heeft Peter Maurer het volgende geschreven:

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 you 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.


*********************************************************
                    ** Alexander Griekspoor **
*********************************************************
              The Netherlands Cancer Institute
              Department of Tumorbiology (H4)
         Plesmanlaan 121, 1066 CX, Amsterdam
                  Tel:  + 31 20 - 512 2023
                  Fax:  + 31 20 - 512 2029
                  E-mail: email@hidden
	        AIM: email@hidden
              Web: http://www.mekentosj.com

                 EnzymeX - To cut or not to cut
             http://www.mekentosj.com/enzymex

*********************************************************


********************************************************* ** Alexander Griekspoor ** ********************************************************* The Netherlands Cancer Institute Department of Tumorbiology (H4) Plesmanlaan 121, 1066 CX, Amsterdam Tel: + 31 20 - 512 2023 Fax: + 31 20 - 512 2029 AIM: email@hidden E-mail: email@hidden Web: http://www.mekentosj.com

                            iRNAi, do you?
             http://www.mekentosj.com/irnai

*********************************************************

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.