Re: Handling right click only
Re: Handling right click only
- Subject: Re: Handling right click only
- From: Severin Kurpiers <email@hidden>
- Date: Tue, 14 Dec 2004 09:01:31 +0100
Hi Alexander,
here is an idea to start with. Create a menu in your nib file and set
the outlet "menu" of your view to the new created menu. Connect menu
items with appropriate actions. Then overwrite the NSView method
menuForEvent: in your NSView subclass to something like this:
- (NSMenu *)menuForEvent:(NSEvent *)event
{
if([event type] == NSRightMouseDown || ([event type] ==
NSLeftMouseDown && ([event modifierFlags] & NSControlKeyMask)))
{
// do whatever you want to do here
}
return [[self nextResponder] menuForEvent:event];
// or, alternatively, maybe it will better suit your needs:
//return nil;
}
Note: This will handle a right mouse click and a left mouse click while
the control key is pressed, which would be probably the expected
behavior in your case.
Hope this helps.
Bye,
Severin Kurpiers
Verek Ltd.
On 14. Dez 2004, Alexander Griekspoor wrote:
Hi all,
Some of you might have seen our funny little app called Disctop which
projects your CD on your desktop. I want to add a few features
including a contextual menu. Now Disctop's main window is set to ignore
any mouse clicks right now and hovers between the desktop background
and the icons of the finder. What I would like to achieve is that
Disctop ONLY accepts the right mouse clicks and presents the contextual
menu in that case, while ALL other events should be forwarded to any
responder which comes next, including those in applications with
windows below ours (read: the finder). Thus, I want to catch the right
clicks but have the left clicks and drags be normally handled by the
finder such that I can still move the desktop icons around.
Any clues?
Many thanks in advance!!
Cheers,
Alex
_______________________________________________
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