• 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
detect "left mouse button clicked in menu bar"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

detect "left mouse button clicked in menu bar"


  • Subject: detect "left mouse button clicked in menu bar"
  • From: "David M. Cotter" <email@hidden>
  • Date: Thu, 13 Aug 2009 14:56:45 -0700

i know i can detect when a particular menu is about to be shown, but what I want is to run a quick process before any menus from the menu bar are shown, and not run it again all the while the user is browsing the menus in the menu bar

how do i do this? apparently there is no "mouseDown" event sent when it's in the menu bar. currently i have this very ugly code:

-(void)sendEvent:(NSEvent *)inEvent
{
	NSEventType		evtType = [inEvent type];

	switch (evtType) {

		//	is this a mouse down in the menu bar?
		case NSSystemDefined: {

			if (
				   [inEvent subtype] == NX_SUBTYPE_AUX_MOUSE_BUTTONS
				&& [inEvent window] == NULL
			) {
				NSPoint						mousePt = [inEvent locationInWindow];
				NSScreen*					screenRef = [NSScreen mainScreen];
				PointF32		myPt;

				//	flip the coordinates
				myPt = TransformScreenPointFromMacScreen(screenRef, mousePt);

				CGFloat			heightF = (CGFloat)[[NSApp mainMenu] menuBarHeight];

				if (myPt.y < heightF && myPt.x < [screenRef frame].size.width) {
					// do my quick process
				}
			}

			break;
		}
			

_______________________________________________

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: detect "left mouse button clicked in menu bar"
      • From: Michael Watson <email@hidden>
    • Re: detect "left mouse button clicked in menu bar"
      • From: Peter Ammon <email@hidden>
  • Prev by Date: Re: Document file read, but -readFromData:(etc) has error.
  • Next by Date: Can I tell [NSAppleScript executeAppleEvent] to wait for script to complete?
  • Previous by thread: Re: iPhone: detect if docked?
  • Next by thread: Re: detect "left mouse button clicked in menu bar"
  • Index(es):
    • Date
    • Thread