# Native menu bar issue?

**URL:** https://forum.juce.com/t/native-menu-bar-issue/10145
**Category:** MacOSX and iOS
**Created:** [March 19, 2013, 7:35am UTC](https://forum.juce.com/t/native-menu-bar-issue/10145 "2013-03-19T07:35:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tomoyuki](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tomoyuki](https://forum.juce.com/u/tomoyuki)
#### Post date: [March 19, 2013, 7:35am UTC](https://forum.juce.com/t/native-menu-bar-issue/10145/1 "2013-03-19T07:35:37Z")

</div>

Hi all,

## Now I’m making a Mac stand-alone app using juce 2.0.38. Then I found a menu bar issue on mac as below.

1. Use native menu bar by MenuBarModel::setMacMainMenu(), and some menu items have shortcut keys.
2. Open popup menu of the menu bar by mouse click.
3. While showing the popup menu, press down any shortcut key (like command+s) and invoke menu item action.
4. Show modal dialog using FileChooser or AlertWindow in the action.
5. After closing the modal dialog, application will crash.

* * *

I’m checking source code around MainMenu, but now I cannot find good countermeasure…  
Can somebody help about this?

Best regards,  
Tomoyuki Kato  
Korg Inc.

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)
#### Post date: [March 19, 2013, 8:42am UTC](https://forum.juce.com/t/native-menu-bar-issue/10145/2 "2013-03-19T08:42:13Z")

</div>

Hmm, I tried this in the introjucer, by right-clicking on some source code to get a popup menu, then hitting cmd-O, but it correctly ignored the shortcut.

Where exactly did it crash?

---

<div class="post-metadata">

### Author: ![tomoyuki](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tomoyuki](https://forum.juce.com/u/tomoyuki)
#### Post date: [March 19, 2013, 11:35am UTC](https://forum.juce.com/t/native-menu-bar-issue/10145/3 "2013-03-19T11:35:51Z")

</div>

Hi jules,

This crash is occurred by menu bar that is located on top of the screen. It is not on right-click popup menu.

## I also tried this in the introjucer, and it occurred. Detailed procedure is as below:

I used zip version of juce, and built it on Xcode 4.2 ( OS X 10.6.8 )  
(downloaded from [https://github.com/julianstorer/JUCE/archive/master.zip](https://github.com/julianstorer/JUCE/archive/master.zip))

1. Launch the introjucer.
2. Click “File” menu on menu bar located on top of the screen. (File popup menu will be shown)
3. Then press down command+O key. Don’t use mouse here. (“Open File” dialog will be shown)
4. Click “Cancel” button and close the dialog.
5. Then the introjucer often crash. (Sometimes it did not happened)

* * *

Then, got following log.  
Debugger stopped at L510 of “juce\_mac\_MainMenu.mm” when I tried debug version. (peer-\>redirectKeyDown (e)😉  
Does this help you?

> [@](#):
>
> Thread 0 Crashed: Dispatch queue: com.apple.main-thread  
> 0 libobjc.A.dylib 0x921ebf87 objc\_msgSend + 23  
> 1 …materialsoftware.introjucer 0x00274d00 juce::NSViewComponentPeer::redirectKeyDown(NSEvent\*) + 80  
> 2 …materialsoftware.introjucer 0x00274992 juce::JuceMainMenuHandler::JuceMenuCallbackClass::menuItemInvoked(objc\_object\*, objc\_selector\*, NSMenuItem\*) + 466  
> 3 com.apple.AppKit 0x9a271a26 -[NSApplication sendAction:to:from:] + 112  
> 4 com.apple.AppKit 0x9a2718d9 -[NSMenuItem \_corePerformAction] + 435  
> 5 com.apple.AppKit 0x9a2715ca -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 174  
> 6 com.apple.AppKit 0x9a2714b6 -[NSMenu performActionForItemAtIndex:] + 65  
> 7 com.apple.AppKit 0x9a271469 -[NSMenu \_internalPerformActionForItemAtIndex:] + 50  
> 8 com.apple.AppKit 0x9a2713cf -[NSMenuItem \_internalPerformActionThroughMenuIfPossible] + 97  
> 9 com.apple.AppKit 0x9a271313 -[NSCarbonMenuImpl \_carbonCommandProcessEvent:handlerCallRef:] + 336  
> 10 com.apple.AppKit 0x9a265a55 NSSLMMenuEventHandler + 404  
> 11 com.apple.HIToolbox 0x972f7c0f DispatchEventToHandlers(EventTargetRec\*, OpaqueEventRef\*, HandlerCallRec\*) + 1567  
> 12 com.apple.HIToolbox 0x972f6ed6 SendEventToEventTargetInternal(OpaqueEventRef\*, OpaqueEventTargetRef\*, HandlerCallRec\*) + 411  
> 13 com.apple.HIToolbox 0x97319773 SendEventToEventTarget + 52  
> 14 com.apple.HIToolbox 0x97345dc7 SendHICommandEvent(unsigned long, HICommand const\*, unsigned long, unsigned long, unsigned char, void const\*, OpaqueEventTargetRef\*, OpaqueEventTargetRef\*, OpaqueEventRef\*\*) + 448  
> 15 com.apple.HIToolbox 0x9736ab38 SendMenuCommandWithContextAndModifiers + 66  
> 16 com.apple.HIToolbox 0x9736aaef SendMenuItemSelectedEvent + 121  
> 17 com.apple.HIToolbox 0x9736a9f7 FinishMenuSelection(SelectionData\*, MenuResult\*, MenuResult\*) + 152  
> 18 com.apple.HIToolbox 0x9733a0ba MenuSelectCore(MenuData\*, Point, double, unsigned long, OpaqueMenuRef\*\*, unsigned short\*) + 454  
> 19 com.apple.HIToolbox 0x97339815 \_HandleMenuSelection2 + 465  
> 20 com.apple.HIToolbox 0x97339633 \_HandleMenuSelection + 53  
> 21 com.apple.AppKit 0x9a25ef96 \_NSHandleCarbonMenuEvent + 285  
> 22 com.apple.AppKit 0x9a233b46 \_DPSNextEvent + 2304  
> 23 com.apple.AppKit 0x9a232dd6 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156  
> 24 com.apple.AppKit 0x9a1f51f3 -[NSApplication run] + 821  
> 25 …materialsoftware.introjucer 0x0012a1ed juce::MessageManager::runDispatchLoop() + 93  
> 26 …materialsoftware.introjucer 0x0025c601 juce::JUCEApplication::main() + 161  
> 27 …materialsoftware.introjucer 0x0025c6d9 juce::JUCEApplication::main(int, char const\*\*) + 57  
> 28 …materialsoftware.introjucer 0x00001e25 start + 53

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)
#### Post date: [March 19, 2013, 1:31pm UTC](https://forum.juce.com/t/native-menu-bar-issue/10145/4 "2013-03-19T13:31:14Z")

</div>

Ok, thanks - I’ve sorted that out now, let me know if you still have problems!

---

<div class="post-metadata">

### Author: ![tomoyuki](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tomoyuki](https://forum.juce.com/u/tomoyuki)
#### Post date: [March 21, 2013, 12:24am UTC](https://forum.juce.com/t/native-menu-bar-issue/10145/5 "2013-03-21T00:24:21Z")

</div>

I updated to the new source code, and checked fixing this.  
Thank you for the quick response and fixing!
