Help with menu?


#1

I’ve been trying to put a menu in my juce app and its not working? I inherited from DocumentWindow which has a menu thing inside. I also defined the virtual menu functions like (getMenubarNames etc… ). I have even have setMenuBar(this, commandManager);

It doesn’t work but it compiles with no errors or warnings. Does anyone have some tutorial or something? :?


#2

Well the demo app and the jucer both have menus - copying that code would be a good place to start…


#3

K ive been trying very hard to get it to work by looking at the demos, AngelJuice, and Jucer. Can anyone just a write a list of the stuff I have to do to get it to work?

Also how can I get the window bar (the one with the app title and maximize, minimize, close buttons to appear)?

Please Any Help at all is really appreciated!!!

Jucer should have a menu editor and it should add menu code? Oh and I found a bug in jucer. When you make the buttons squared for example, that only appears till after you add a LookAndFeel, in my case I added code to create a ShinyLookAndFeel, something that jucer didnt add so my app didnt have square buttons like it did in jucer. :?


#4

[quote=“grizzley90”]K ive been trying very hard to get it to work by looking at the demos, AngelJuice, and Jucer. Can anyone just a write a list of the stuff I have to do to get it to work?

Also how can I get the window bar (the one with the app title and maximize, minimize, close buttons to appear)?

Please Any Help at all is really appreciated!!!

Jucer should have a menu editor and it should add menu code? Oh and I found a bug in jucer. When you make the buttons squared for example, that only appears till after you add a LookAndFeel, in my case I added code to create a ShinyLookAndFeel, something that jucer didnt add so my app didnt have square buttons like it did in jucer. :?[/quote]

The two things you need to implement are ApplicationCommandTarget and MenuBarModel, so look at the help for ApplicationCommandTarget, or copy the way the demo does it. Then use DocumentWindow::setMenuBar to enable the menu for your document window. That’s it really. The MainDemoWindow.cpp file in the demo does everything you’d need to do.

No idea how you’d fail to get a title bar if you’re using a DocumentWindow. You are using a DocumentWindow, aren’t you?

And that’s not a jucer bug - you app should set its look and feel globally at start-up, not on a per-component basis. The jucer lets you change the look-and-feel so you can see what it looks like, but it doesn’t store anything about it in the code for each component.


#5

To hopefully make things a bit easier for those trying to get a grasp on Juce and also to get myself acquainted with the API, I’m working on a bunch of small demo projects which I shall make available as soon as ready. Unfortunately, I’m still a newbie to both C++ and Juce, so these projects will likely be a bit noobish. But then, I’m making them available for free, so who can complain.

I haven’t worked out the details for a window with a menubar yet, but it shouldn’t be long before that’s ready. For now, here’s a small example project which is sort of a template project for use outside of Jucer.

The main.cpp file can be edited in Jucer and then the project can be compiled, the MainWindow portion already including everything necessary for the Jucer file to be included. Basically, main.cpp is the heart of the program. The project has been setup using Dev-C++, but can easily be moved into a better IDE.

The project is meant to be put in a folder within the Juce\Jucer folder. I have it setup under Juce\Jucer\Projects. Follow the link for the files.

http://www.esnips.com/web/JuceStuff

Oh and Jules, the “Hello world” example project doesn’t have a window at all. That might perhaps be what grizzley was using as a starting point, as I once did. It’s a tough starting point file and so is the jucedemo, which is awesome, yet bulky for newbies.

Please feel free to do with this example project as you wish. There will be more to come soon.

God bless,
Dave


#6

Good point about the hello-world app. It’s very old now, so I might tart it up a bit.

Had a quick look at your app (thanks for being so public-spirited, BTW!). Looks good, but you should never use addAndMakeVisible() directly on a DocumentWindow - use setContentComponent instead and put any other components inside the content comp. Reasons for this are all explained in the ResizableWindow class. (I should probably find a way of causing an assertion to stop people getting this wrong, as I admit it’s not obvious).


#7

Thanks for the note Jules. I fixed the file and re-uploaded it.


#8