• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Handling right click only
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling right click only


  • Subject: Re: Handling right click only
  • From: Alexander Griekspoor <email@hidden>
  • Date: Tue, 14 Dec 2004 14:19:59 +0100

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Handling right click only
      • From: Guy English <email@hidden>
  • Prev by Date: Re: NSProgressIndicator, MUST use threads?
  • Next by Date: Re: NSProgressIndicator, MUST use threads?
  • Previous by thread: Re: Handling right click only
  • Next by thread: Re: Handling right click only
  • Index(es):
    • Date
    • Thread