• 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: Simulating menu bar blink in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simulating menu bar blink in Cocoa


  • Subject: Re: Simulating menu bar blink in Cocoa
  • From: John Stiles <email@hidden>
  • Date: Sat, 19 Apr 2008 17:36:37 -0700

No, that's not the problem. The problem is that some combinations simply don't work. For instance, just as a random example, AppKit does not match "option+," or "shift+`". (Haven't tried adding command but offhand I don't have any reason to think that this would fix it.)

My app supports arbitrary, user-defined hotkeys, so I am finding a lot of edge cases.

Also, AppKit has other problems where it will send hotkeys to the first responder instead of to the menubar directly if they don't contain the command key. This didn't work for me either, so I already needed a workaround in -sendEvent:. At the end of the day it was much simpler for me to match hotkeys myself instead of putting in kludge after kludge to make the AppKit hotkey matching work as I needed it to.

I have radars filed on some of these behaviors but I need it to work on today's OS, warts and all :)


Benjamin Stiglitz wrote:
If I understand well, your trying to catch event that match a menu item shortcut minus the shift key. Isn't it possible to override -[NSApp sendEvent:] as you did, but instead of taking care of the event yourself, create a new event that match the menu item and then call super with this new event ?

- (void)sendEvent:(NSEvent *)theEvent { if ([theEvent isAnHotkeyEvent]) { theEvent = [NSEvent eventWithTheKeystrokeAppKitWant]; } [super sendEvent:theEvent]; }


I really don't know if it works, but it worth the try.

That’s a pretty common way to do it, and avoids the need to duplicate the actual method dispatch. Works great.


-Ben
_______________________________________________

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: 
 >Simulating menu bar blink in Cocoa (From: John Stiles <email@hidden>)
 >Re: Simulating menu bar blink in Cocoa (From: Benjamin Stiglitz <email@hidden>)
 >Re: Simulating menu bar blink in Cocoa (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Simulating menu bar blink in Cocoa (From: Benjamin Stiglitz <email@hidden>)

  • Prev by Date: drawRect: called twice for NSView subclass.
  • Next by Date: Re: [SOLVED] Simulating menu bar blink in Cocoa
  • Previous by thread: Re: Simulating menu bar blink in Cocoa
  • Next by thread: Implementing NSHUDWindowMask on NSDrawer
  • Index(es):
    • Date
    • Thread