• 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: Dismissing menu from menu item that uses custom view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dismissing menu from menu item that uses custom view


  • Subject: Re: Dismissing menu from menu item that uses custom view
  • From: Lee Ann Rucker <email@hidden>
  • Date: Wed, 29 May 2013 16:46:18 -0700

Don't delay the action/target part, write a wrapper function and delay that:

- (void)mouseUp:(NSEvent*)event
{
	UNUSED_VAR(event);

	NSMenuItem*		item = [self enclosingMenuItem];
	NSMenu*			menu = [item menu];
	// On mouseUp, we want to dismiss the menu being tracked:
	[menu cancelTracking];
	[self performSelector:@selector(delayedSendAction:) withObject:item afterDelay:0];
}

- (void)delayedSendAction: (NSMenuItem *)item
{
	// Then send the action to the target:
	SEL				act = [item action];
	id				targ = [item target];

	if(act != nil && targ != nil)
//		[NSApp sendAction:act to:targ from:item];
// Temporarily sending the About menu item so it'll fire the About box:
		[NSApp sendAction:act to:targ from:[menu itemAtIndex:0]];

// Copied from MenuItemView sample project. I don't think this is necessary:
//	[self setNeedsDisplay:YES];
}
On May 29, 2013, at 4:34 PM, Steve Mills wrote:

> On May 29, 2013, at 18:06:45, Lee Ann Rucker <email@hidden>
> wrote:
>
>> Use performSelector:withObject:afterDelay:0 to push your response to the end of the run loop, giving the UI a chance to update first. It's what I do when a button (etc) is going to trigger something that won't be instantaneous, where the button shouldn't keep showing in the pressed state while it happens.
>
> Good idea, but I need to send the 3rd parameter; the selector, the target, and the sender. I can't do that with performSelector:withObject:afterDelay:.
>
> --
> Steve Mills
> office: 952-818-3871
> home: 952-401-6255
> cell: 612-803-6157
>
>
>
> _______________________________________________
>
> 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

  • Follow-Ups:
    • Re: Dismissing menu from menu item that uses custom view
      • From: Steve Mills <email@hidden>
References: 
 >Dismissing menu from menu item that uses custom view (From: Steve Mills <email@hidden>)
 >Re: Dismissing menu from menu item that uses custom view (From: Lee Ann Rucker <email@hidden>)
 >Re: Dismissing menu from menu item that uses custom view (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: Dismissing menu from menu item that uses custom view
  • Next by Date: Re: Dismissing menu from menu item that uses custom view
  • Previous by thread: Re: Dismissing menu from menu item that uses custom view
  • Next by thread: Re: Dismissing menu from menu item that uses custom view
  • Index(es):
    • Date
    • Thread