# Example for attaching Mac Edit menu bar items when TextEditor has focus?

**URL:** <https://forum.juce.com/t/example-for-attaching-mac-edit-menu-bar-items-when-texteditor-has-focus/29980>\
**Category:** MacOSX and iOS\
**Created:** [October 22, 2018, 7:36pm UTC](https://forum.juce.com/t/example-for-attaching-mac-edit-menu-bar-items-when-texteditor-has-focus/29980 "2018-10-22T19:36:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkoutavas](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jkoutavas/32/147_2.png) [@jkoutavas](https://forum.juce.com/u/jkoutavas)\
**Post date:** [October 22, 2018, 7:36pm UTC](https://forum.juce.com/t/example-for-attaching-mac-edit-menu-bar-items-when-texteditor-has-focus/29980/1 "2018-10-22T19:36:16Z")

</div>

Hi. Can anyone point me to an example of how to wire-up my Mac JUCE app’s Edit menu items to appear and be properly active when a TextEditor field has the focus? I would expect to have seen this capability in Projucer itself, when editing IDE settings and the like, but such is not the case. There’s only the right-click popup menu edit items. Basically, I’d like those actions tied into the main menu’s Edit menu pull down.

Thank you!

/Jay

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [October 22, 2018, 11:08pm UTC](https://forum.juce.com/t/example-for-attaching-mac-edit-menu-bar-items-when-texteditor-has-focus/29980/2 "2018-10-22T23:08:47Z")

</div>

[https://docs.juce.com/develop/classApplicationCommandManager.html](https://docs.juce.com/develop/classApplicationCommandManager.html)

you gotta do some stuff in the guts of your implementation of how it populates the menu to check flags as to whether or not a menu item should be enabled or not.

when you add your menu bar, the menubar model, and associate it with the ApplicationCommandManager, the function that returns the popup menu for the menu bar is where you’ll check whether your menu item should be enabled/checked/etc.

at least, that’s what my experience was when I had to do it.

---

<div class="post-metadata">

**Author:** ![jkoutavas](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jkoutavas/32/147_2.png) [@jkoutavas](https://forum.juce.com/u/jkoutavas)\
**Post date:** [October 22, 2018, 11:14pm UTC](https://forum.juce.com/t/example-for-attaching-mac-edit-menu-bar-items-when-texteditor-has-focus/29980/3 "2018-10-22T23:14:01Z")

</div>

Thank you, …but, TextEditor does this already with it’s pop-up Edit menu. I would have expected it to be a couple of lines of code to route the pop-up’s logic to the Mac Menu bar’s Edit menu. Thus why I was asking for an example.

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [October 22, 2018, 11:27pm UTC](https://forum.juce.com/t/example-for-attaching-mac-edit-menu-bar-items-when-texteditor-has-focus/29980/4 "2018-10-22T23:27:16Z")

</div>

Maybe there is a way to capture the popup menu that’s passed to

```auto
void TextEditor::addPopupMenuItems	(	PopupMenu & menuToAddTo,
const MouseEvent * mouseClickEvent 

```

and give that to your MenuBarModel…

---

<div class="post-metadata">

**Author:** ![jkoutavas](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jkoutavas/32/147_2.png) [@jkoutavas](https://forum.juce.com/u/jkoutavas)\
**Post date:** [October 22, 2018, 11:29pm UTC](https://forum.juce.com/t/example-for-attaching-mac-edit-menu-bar-items-when-texteditor-has-focus/29980/5 "2018-10-22T23:29:10Z")

</div>

Thank you, I’ll give that a try.

I find it rather interesting that such a fundamental Mac thing as operating the Mac’s Edit menu while doing TextEditor operations isn’t a readily known JUCE pattern. Maybe I’ll open a GitHub example for how to do it once I get it sorted out. 🙂
