ApplicationCommandTarget's perform function not firing


#1

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


#2

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!


#3

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…


#4

[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”


#5

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.


#6

[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?


#7

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

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

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!


#8

Well, that’s not obvious at all.

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

Thank you :slight_smile: