# Native menus on mac?

**URL:** <https://forum.juce.com/t/native-menus-on-mac/1490>\
**Category:** MacOSX and iOS\
**Created:** [February 21, 2007, 12:25pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490 "2007-02-21T12:25:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans](https://avatars.discourse-cdn.com/v4/letter/h/e19b73/32.png) [@Hans](https://forum.juce.com/u/Hans)\
**Post date:** [February 21, 2007, 12:25pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/1 "2007-02-21T12:25:26Z")

</div>

Is it possible to implement native OS X menus using JUCE?

---

<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:** [February 21, 2007, 3:37pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/2 "2007-02-21T15:37:51Z")

</div>

I’ve not done this yet, but it’s on my to-do list!

---

<div class="post-metadata">

**Author:** ![stick](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@stick](https://forum.juce.com/u/stick)\
**Post date:** [June 26, 2007, 3:24pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/3 "2007-06-26T15:24:29Z")

</div>

Now it is done ! thanks a lot 🙂

When using the OSX menuBar, the juce demo makes an assertion at shutdown when trying to remove the listener of the MenuBarModel :

```auto
void MenuBarModel::removeListener (MenuBarModelListener* const listenerToRemove) throw()
{
    // Trying to remove a listener that isn't on the list!
    // If this assertion happens because this object is a dangling pointer, make sure you've not
    // deleted this menu model while it's still being used by something (e.g. by a MenuBarComponent)
    jassert (listeners.contains (listenerToRemove));

    listeners.removeValue (listenerToRemove);
```

What’s the better way to avoid this assertion ?

When adding setMacMainMenu(0) in the destructor of ContentComp (inheriting from MenuBarModel) everything seems alright…

---

<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:** [June 26, 2007, 4:11pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/4 "2007-06-26T16:11:50Z")

</div>

Yes - like it says, just make sure the model isn’t deleted before being removed. Calling setMacMainMenu(0) is the way to do it.

---

<div class="post-metadata">

**Author:** ![bruce-wheaton](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@bruce-wheaton](https://forum.juce.com/u/bruce-wheaton)\
**Post date:** [June 27, 2007, 5:57pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/5 "2007-06-27T17:57:57Z")

</div>

I just found this too. I had to add the setmenu(0) to my destructor.

Bruce

---

<div class="post-metadata">

**Author:** ![peteatjuce](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/peteatjuce/32/2347_2.png) [@peteatjuce](https://forum.juce.com/u/peteatjuce)\
**Post date:** [July 20, 2007, 12:55pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/6 "2007-07-20T12:55:45Z")

</div>

Hi Jules,

Could I please make a request that if a Menu item is called “About…” or “Preferences” (or maybe this is indicated with some soft of menu item “hint flag” identifying it has a special meaning to the user/OS), and if the native Mac menu is being used, then those items are put under the left-hand Mac native menu bar item? On Mac apps, the About and Preferences items are always found there, with a separator too.

That would allow mac-native Juce app menus to behave just like normal Mac app menus… which would be cool!

Anyways, hoping that makes sense. 🙂

Pete

---

<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:** [July 20, 2007, 1:14pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/7 "2007-07-20T13:14:47Z")

</div>

Would love to do that, but couldn’t find any way of accessing that menu programatically. (I think there’s a thread about it somewhere…)

---

<div class="post-metadata">

**Author:** ![peteatjuce](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/peteatjuce/32/2347_2.png) [@peteatjuce](https://forum.juce.com/u/peteatjuce)\
**Post date:** [July 21, 2007, 7:26am UTC](https://forum.juce.com/t/native-menus-on-mac/1490/8 "2007-07-21T07:26:28Z")

</div>

Just for reference… keeping it all in one place, as it were…🙂 !

[http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html](http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html)

> [@](#):
>
> The Application Menu Contents
> 
> About ApplicationName. Opens your application’s About window, which contains copyright information and version number. (For more information, see “About Windows.” If you’ve specified a short name (see “The Application Menu Title”), use it in the About menu item; use the full application name in the About window.
> 
> Preferences… (Command-,). Opens a preference window for your application. See Multiple User Environments for more information on handling preferences in a multiple-user environment.

[http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html](http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html)

> [@](#):
>
> Carbon: Use HIAboutBox to provide a default About window. You can designate specific settings in your application’s Info.plist file.  
> Cocoa: An About window is provided automatically by the Application Kit; set the relevant information in your application’s Info.plist file.

[http://developer.apple.com/documentation/Carbon/Conceptual/HIViewDoc/HIView\_tasks/chapter\_3\_section\_12.html](http://developer.apple.com/documentation/Carbon/Conceptual/HIViewDoc/HIView_tasks/chapter_3_section_12.html)

> [@](#):
>
> Beginning in Mac OS X v10.3, all menus are implemented as views. This feature allows additional flexibility in creating or modifying menus. The actual menu content views are created lazily, as needed. That is, the Menu Manager does not create the menu content view, or even the owning window/root view/content view hierarchy that holds it, until the user first clicks on a menu title in the menu bar.

[http://developer.apple.com/documentation/Carbon/Conceptual/HIViewDoc/HIView\_tasks/chapter\_3\_section\_15.html#//apple\_ref/doc/uid/TP30000923-CH205-BAJHJCBC](http://developer.apple.com/documentation/Carbon/Conceptual/HIViewDoc/HIView_tasks/chapter_3_section_15.html#//apple_ref/doc/uid/TP30000923-CH205-BAJHJCBC)

> [@](#):
>
> One of the advantages of HIView is that you can subclass an existing view when creating a custom view. In object-oriented fashion, a view is essentially a class defined by Carbon event handlers (essentially methods) and instance data. To create a custom view, you must create a subclass of HIView and add your custom functionality by overriding event handlers.

Anyways, HTH! The key thing might be that from MacOS 10.3, all menus are now implemented as HIViews; presumably this implies that it must be possible now to do what you want programmatically… 🙂

Pete

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [August 30, 2007, 9:07pm UTC](https://forum.juce.com/t/native-menus-on-mac/1490/9 "2007-08-30T21:07:59Z")

</div>

My app repaints everytime a timer fires. However, if I open a native menu, the app stops repainting.

---

<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:** [August 31, 2007, 8:31am UTC](https://forum.juce.com/t/native-menus-on-mac/1490/10 "2007-08-31T08:31:28Z")

</div>

> [@G-Mon](#):
>
> My app repaints everytime a timer fires. However, if I open a native menu, the app stops repainting.

…yes, I think most mac apps will do the same - when you open the menus with MenuSelect, it goes into a modal loop that doesn’t let all the messages through. That function seems to be left-over from the old days of OS9, not sure if they’ve got a better way of doing it now.

---

<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:** [May 12, 2017, 10:14am UTC](https://forum.juce.com/t/native-menus-on-mac/1490/11 "2017-05-12T10:14:16Z")

</div>

Closed on May 12, 2017, 10:14am UTC


