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