• 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: Accessing [event modifierFlags] in an action method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing [event modifierFlags] in an action method?


  • Subject: Re: Accessing [event modifierFlags] in an action method?
  • From: Matt Gough <email@hidden>
  • Date: Tue, 20 May 2008 14:39:20 +0200

Thanks,

I knew there would be a simple way.

Matt

On 20 May 2008, at 14:21, Graham Cox wrote:

[[NSApp currentEvent] modifierFlags];

hth,

G.

On 20 May 2008, at 10:16 pm, Matt Gough wrote:


I have an action method for a disclosure button :

-(IBAction) toggleText:(id) sender
{
	[self doSomethingUseful];
}

I now want it to behave slightly differently if the command key was down when the button was clicked, but can see no 'simple' way to get the state of the modifier keys from with the action method.

OK I do know a way, I could call GetCurrentKeyModifiers() or GetCurrentEventKeyModifiers() in toggleText, but I was really looking for a way to get the NSEvent that was used to trigger the action.
I could probably also subclass NSButton and keep hold of the event or modifierFlags inside mouseDown and pick up on them inside of toggleText.


This seems such a common thing to want to do that I am sure there is a simple and correct way to do it. However that path currently eludes me.

Thanks

Matt
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Accessing [event modifierFlags] in an action method? (From: Matt Gough <email@hidden>)
 >Re: Accessing [event modifierFlags] in an action method? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Initialize a subclass object with a base class object
  • Next by Date: Re: Initialize a subclass object with a base class object
  • Previous by thread: Re: Accessing [event modifierFlags] in an action method?
  • Next by thread: check if app opens with a document on startup
  • Index(es):
    • Date
    • Thread