# Prevent application from beeping

**URL:** <https://forum.juce.com/t/prevent-application-from-beeping/4743>\
**Category:** MacOSX and iOS\
**Created:** [January 19, 2010, 10:46am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743 "2010-01-19T10:46:08Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [January 19, 2010, 10:46am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/1 "2010-01-19T10:46:08Z")

</div>

I use setMacMainMenu to add menu items to the application menu, some items have shortcuts.  
Sometimes when i select an item in the menu or use the shortcut OSX gives me a beep, it’s a standard beep that is used all over the system if an action that is taken can’t be executed.  
When using the rest of the menu i never get beeps when actions can’t be executed.  
As we are making Audio software i don’t want this beep to be audible, does anyone have a clue to disable this. It this something you could disable on application level?

---

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [January 19, 2010, 10:53am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/2 "2010-01-19T10:53:08Z")

</div>

I found this, it probably removes some beeps from my application but does not prevent my menu generating them.  
void MyLookAndFeel::playAlertSound()  
{  
return; // instead of PlatformUtilities::beep();  
}

---

<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:** [January 19, 2010, 4:10pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/3 "2010-01-19T16:10:54Z")

</div>

It only beeps when your menu sends a command that isn’t accepted by any command target. If your commands and targets are set up correctly, it shouldn’t need to beep!

---

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [January 20, 2010, 1:31pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/4 "2010-01-20T13:31:06Z")

</div>

Well, before i moved the items to the macMainMenu they never beeped, and they never needed to either (because i do think i have setup things correctly). I will try to see if i can reproduce the beeps in the Juce Demo with the latest GIT version.

And if i’m doing things wrong or when a no target is found for a command, how to prevent it from beeping. I would like to never have beeps if possible.

---

<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:** [January 20, 2010, 4:12pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/5 "2010-01-20T16:12:35Z")

</div>

Well, I use mac main menus without beeping problems, but if you can create some demo code that shows the problem, I’ll take a look…

---

<div class="post-metadata">

**Author:** ![jaydee](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jaydee](https://forum.juce.com/u/jaydee)\
**Post date:** [January 20, 2010, 6:53pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/6 "2010-01-20T18:53:42Z")

</div>

I’m not quite up to date with the tip(about 8 days behind), but I just noticed my key mappings stopped working… The command manager is still called when I go to the menu manually(not using native toolbar), but just beep when I hit the key commands…

Just thought i’d mention it, i’ll update to git and try to track it down

[EDIT] - JUCE demo is working fine…so it must be me…

---

<div class="post-metadata">

**Author:** ![jaydee](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jaydee](https://forum.juce.com/u/jaydee)\
**Post date:** [January 20, 2010, 7:17pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/7 "2010-01-20T19:17:54Z")

</div>

I’m building against 10.4u SDK and had to add this to my CFLAGS…

-DMACOS\_10\_4\_OR\_EARLIER=1

so that the mac peer would implement performKeyEquivalent. Otherwise it’s not getting compiled…

In my project I have deployment target as 10.4… I’m not sure where if anywhere JUCE defines MACOS\_10\_4\_OR\_EARLIER, or if we’re responsible for it, but it fixed me… (until my next GIT update anyways!)

---

<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:** [January 20, 2010, 8:18pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/8 "2010-01-20T20:18:54Z")

</div>

Oh, looks like I missed a couple of the old OSX macros when I updated them. Instead of MACOS\_10\_4\_OR\_EARLIER, it should read:  
#if MAC\_OS\_X\_VERSION\_MIN\_REQUIRED \< MAC\_OS\_X\_VERSION\_10\_5

Thanks, I’ll tidy that up.

---

<div class="post-metadata">

**Author:** ![cxhawk](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@cxhawk](https://forum.juce.com/u/cxhawk)\
**Post date:** [January 22, 2010, 7:38am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/9 "2010-01-22T07:38:34Z")

</div>

[quote=“gekkie100”]I use setMacMainMenu to add menu items to the application menu, some items have shortcuts.  
Sometimes when i select an item in the menu or use the shortcut OSX gives me a beep, it’s a standard beep that is used all over the system if an action that is taken can’t be executed.  
When using the rest of the menu i never get beeps when actions can’t be executed.  
As we are making Audio software i don’t want this beep to be audible, does anyone have a clue to disable this. It this something you could disable on application level?[/quote]

I also have this problem sometimes on toolbar item which is registered as a command. After I click on a toolbar item (such as open), it beeps. But the command get executed. It’s not 100% reproducible.

---

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [January 22, 2010, 2:20pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/10 "2010-01-22T14:20:12Z")

</div>

I’m not able yet to reproduce the problem in the Juce demo. Like with cxhawk my commands do get executed but give a beep. Only beeps though when the command has a shortcut attached. I will investigate further.

---

<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:** [January 22, 2010, 4:27pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/11 "2010-01-22T16:27:38Z")

</div>

The jucer uses shortcut keys - maybe try to reproduce it in there?

---

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [February 23, 2010, 11:28am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/12 "2010-02-23T11:28:20Z")

</div>

After fixing some more important bugz in our software in the mean time, i return back to the beep issue.  
Luckily i found a way to reproduce it, so Jules maybe you can help me out here.  
When you click (or use a shortcut) on items that are added to the Apple menu using the extraAppleMenuItems parameter in MenuBarModel::setMacMainMenu(), they beep.  
I modified the code in the Demo project to reproduce the problem.

```auto
    const PopupMenu getMenuForIndex (int menuIndex,
                                     const String& menuName)
    {
        ApplicationCommandManager* const commandManager = mainWindow->commandManager;

        PopupMenu menu;

        if (menuIndex == 0)
        {
            menu.addCommandItem (commandManager, showRendering);
            menu.addCommandItem (commandManager, showFontsAndText);
            menu.addCommandItem (commandManager, showWidgets);
            menu.addCommandItem (commandManager, showThreading);
            //menu.addCommandItem (commandManager, showTreeView);
            menu.addCommandItem (commandManager, showTable);
            menu.addCommandItem (commandManager, showAudio);
            menu.addCommandItem (commandManager, showDragAndDrop);
            menu.addCommandItem (commandManager, showOpenGL);
            menu.addCommandItem (commandManager, showQuicktime);
.......
```

```auto

        case useNativeMenus:
            if (MenuBarModel::getMacMainMenu() != 0)
            {
                MenuBarModel::setMacMainMenu (0);
                mainWindow->setMenuBar ((ContentComp*) mainWindow->getContentComponent());
            }
            else
            {
				PopupMenu* extraItems = new PopupMenu();
				extraItems->addCommandItem(mainWindow->commandManager, showTreeView, T("extra show treeview"));

                MenuBarModel::setMacMainMenu ((ContentComp*) mainWindow->getContentComponent(), extraItems);
                mainWindow->setMenuBar (0);
            }

            break;
```

I tracked the beep down and it seems that flashMenuBar is the one that’s causing the beep.  
It beeps when calling performKeyEquivalent.

```auto
[menu performKeyEquivalent: f35Event];
```

---

<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 23, 2010, 6:47pm UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/13 "2010-02-23T18:47:39Z")

</div>

Thanks, I’ll get that sorted out…

---

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [February 26, 2010, 9:15am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/14 "2010-02-26T09:15:44Z")

</div>

Did you had time to look at this already?

---

<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 26, 2010, 10:20am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/15 "2010-02-26T10:20:11Z")

</div>

¥eah, that’s fixed.

---

<div class="post-metadata">

**Author:** ![rebbur](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@rebbur](https://forum.juce.com/u/rebbur)\
**Post date:** [February 26, 2010, 10:49am UTC](https://forum.juce.com/t/prevent-application-from-beeping/4743/16 "2010-02-26T10:49:04Z")

</div>

Thanx Jules, i found the fix and it works!
