# ApplicationCommandTarget's perform function not firing

**URL:** <https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571>\
**Category:** General JUCE discussion\
**Created:** [February 13, 2008, 10:02pm UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571 "2008-02-13T22:02:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![raiko](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/raiko/32/450_2.png) [@raiko](https://forum.juce.com/u/raiko)\
**Post date:** [February 13, 2008, 10:02pm UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/1 "2008-02-13T22:02:38Z")

</div>

Hello,

I’m trying to get my menuing to work. I started off with the beginner code posted here and built from there.

My menus show up, but they do nothing when I click them. If I use the standard command ids like quit, that works.

Could someone please take a look and tell me what I’m missing?

Thank you

[http://www.2shared.com/file/2842454/72be5aa8/NCAA.html](http://www.2shared.com/file/2842454/72be5aa8/NCAA.html)

---

<div class="post-metadata">

**Author:** ![giogio](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@giogio](https://forum.juce.com/u/giogio)\
**Post date:** [February 14, 2008, 10:22am UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/2 "2008-02-14T10:22:33Z")

</div>

I have the same problem…  
I check the jucedemo and I think I did the same things…  
but it doesn’t work in my project… :evil:  
Some not trivial things needed… as “juce\_UseDebuggingNewOperator”?  
thanx!

---

<div class="post-metadata">

**Author:** ![giogio](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@giogio](https://forum.juce.com/u/giogio)\
**Post date:** [February 14, 2008, 10:54am UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/3 "2008-02-14T10:54:00Z")

</div>

I found a solution… maybe I haven’t really understood the idea BUT…  
if you use a Class that is a Component, a MenuBarModel and a ApplicationCommandTarget and…  
in your DocumentWindow class you do:

setContentComponent(mainMenu);  
setMenuBar(mainMenu);

… mainMenu is an instance of the “Component, MenuBarModel and ApplicationCommandTarget” everything works!

I would like to use a class for the ContentComponent and another for  
the Menu… but maybe I made some mistakes…

I hope what I wrote is clear… my English is not great…

---

<div class="post-metadata">

**Author:** ![raiko](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/raiko/32/450_2.png) [@raiko](https://forum.juce.com/u/raiko)\
**Post date:** [February 14, 2008, 1:59pm UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/4 "2008-02-14T13:59:36Z")

</div>

[quote=“giogio”]I found a solution… maybe I haven’t really understood the idea BUT…  
if you use a Class that is a Component, a MenuBarModel and a ApplicationCommandTarget and…  
in your DocumentWindow class you do:

setContentComponent(mainMenu);  
setMenuBar(mainMenu);

… mainMenu is an instance of the “Component, MenuBarModel and ApplicationCommandTarget” everything works!

I would like to use a class for the ContentComponent and another for  
the Menu… but maybe I made some mistakes…

I hope what I wrote is clear… my English is not great…[/quote]

I already do that in my code. The menu comes up and I can click it, but the actions never fire. The only one that works is the Standard Command “Quit”

---

<div class="post-metadata">

**Author:** ![valley](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@valley](https://forum.juce.com/u/valley)\
**Post date:** [February 14, 2008, 3:03pm UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/5 "2008-02-14T15:03:54Z")

</div>

any component, or class that wants to receive application command events must:

a) be a descendant of ApplicationCommandTarget.

b) be registered by a call to ApplicationCommandManager::registerAllCommandsForTarget()

Then you need to give some thought to how your event will trickle up to the target. If the target is a focussed component, you’re fine. Otherwise, you might need to do something clever in a parent component to endure that the command callback reaches the desired target.

---

<div class="post-metadata">

**Author:** ![raiko](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/raiko/32/450_2.png) [@raiko](https://forum.juce.com/u/raiko)\
**Post date:** [February 14, 2008, 3:54pm UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/6 "2008-02-14T15:54:05Z")

</div>

[quote=“valley”]any component, or class that wants to receive application command events must:

a) be a descendant of ApplicationCommandTarget.

b) be registered by a call to ApplicationCommandManager::registerAllCommandsForTarget()

Then you need to give some thought to how your event will trickle up to the target. If the target is a focussed component, you’re fine. Otherwise, you might need to do something clever in a parent component to endure that the command callback reaches the desired target.[/quote]

I’ve done A and B.

The menu is coming from the component, not the main window. The reason for doing that is so I can keep all button control code in the same place. I was trying to follow the demo and it just doesn’t seem to be working.

Can you read the code I posted and maybe spot the problem?

---

<div class="post-metadata">

**Author:** ![giogio](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@giogio](https://forum.juce.com/u/giogio)\
**Post date:** [February 18, 2008, 10:01am UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/7 "2008-02-18T10:01:44Z")

</div>

Hi raiko!  
I found the problem in your code…  
in

```auto

```

you did:`
case CommandIDs::opencsv:
		result.defaultKeypresses.add(KeyPress (T('o'), cmd, 0));
		break;`  
but this is not enough, you have to add

```auto

```

…

`case CommandIDs::opencsv:
		result.setInfo(T("AAA"), T("BBB"), T("CCC"), 0);
		result.defaultKeypresses.add(KeyPress (T('o'), cmd, 0));
		break;`

this for ALL the command, even About… if you try compiling in Debug  
mode your code (Multi-threaded Debug (/MTd)) you will understand why nothing happened…  
no info for the commands --\> no commands!  
bye!

---

<div class="post-metadata">

**Author:** ![raiko](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/raiko/32/450_2.png) [@raiko](https://forum.juce.com/u/raiko)\
**Post date:** [February 18, 2008, 4:29pm UTC](https://forum.juce.com/t/applicationcommandtargets-perform-function-not-firing/2571/8 "2008-02-18T16:29:45Z")

</div>

Well, that’s not obvious at all.

I thought that the text was just used for displaying help or something.

Thank you 🙂
