Forcing a popup menu to close


#1

Hello

I’m looking for a way to force a popumenu to close without the user intervention, is there a way ?

edit: I’m currently writing my own menubar class because I can’t get the Menubar component to work.

All I get is “cannot instantiate abstract class due to following members: class mainMenuComponent : public Component, public MenuBarModel”

My class declaration is very simple:

class mainMenuComponent : public Component, public MenuBarModel
						
						  
{
public:
	mainMenuComponent();
	virtual ~mainMenuComponent();
	MenuBarComponent* menuBar;
       addAndMakeVisible(menuBar);

	const StringArray getMenuBarNames (MenuBarComponent* menuBarCmp);
	const PopupMenu getMenuForIndex (MenuBarComponent* menuBar,
                                     int menuIndex, 
                                     const String& menuName);


};

and the class itself:

[code]
mainMenuComponent::mainMenuComponent()
{
menuBar = new MenuBarComponent(this);
}

mainMenuComponent::~mainMenuComponent()
{
}

const StringArray mainMenuComponent::getMenuBarNames (MenuBarComponent* menuBarCmp)
{
StringArray s;
s.add(T(“File”));
return s;
}

const PopupMenu mainMenuComponent::getMenuForIndex (MenuBarComponent* menuBar,
int menuIndex,
const String& menuName)
{
PopupMenu menu;

return menu;

}[/code]


#2

how do you mean?

do you mean if the user hasnt made a selection from the popup?

a Timer? wait a while then close it.

or get a parent component to intercept clicks then close it. no that happens anyway doesnt it?

:o

not following you to be honest!

tell us more.


#3

actually I want the popup to close when the mouse enter a button. typically like a menubar, if your mouse is over the File menu, the menu file is opened, but if the mouse cursor go over another menu in the menu bar, that it close the first popup and open the new one.


#4

and why doesn’t the menubar component work for you? is its behaviour inappropriate? or have you just done it wrong? you could always ask us for advice on how to get THAT working instead, because jules’ demo app shows that it works…


#5

this is why I edited my message as I’d prefer to use the menubar component. I posted my class, I can’t see what’s wrong (I’m new to c++ :p)


#6

just noticed that I forgot the menuItemSelect function :oops:

Now it compiles, but I can’t see it, the component is displayed, but the menubar is invisible :x


#7

it’s a MenuBarComponent you want.

behaves as you have specified. theres one in the jucedemo.

create your class as above but don’t inheret from Component.

pass an object of your class into MenuBarComponents constructor and your off


#8

[quote=“Karbon L. Forms”]
create your class as above but don’t inheret from Component.
pass an object of your class into MenuBarComponents constructor and your off[/quote]

I’m not following you, beside not inheriting from Component. How do you pass an object, and what object ?

The MenuBarComponents constructor has ‘this’ has a parameter, that will set the BarMenuModel


#9

right OK I’m starting to follow you now! :lol:

right scratch what I said. wasnt paying attention.

ok

this…

MenuBarComponent* menuBar;
addAndMakeVisible(menuBar);

looks a bit dodgy.

whats addAndMakeVisible doing there? that should be in your constructor. no?

mainMenuComponent::mainMenuComponent()
{
menuBar = new MenuBarComponent(this);
addAndMakeVisible(menuBar);
}

you’ll need to give it a size in resized or something.

ouch. too wrecked for this!


#10

[quote=“Karbon L. Forms”]right OK I’m starting to follow you now! :lol:

right scratch what I said. wasnt paying attention.

ok

this…

MenuBarComponent* menuBar;
addAndMakeVisible(menuBar);

looks a bit dodgy.

whats addAndMakeVisible doing there? that should be in your constructor. no?

mainMenuComponent::mainMenuComponent()
{
menuBar = new MenuBarComponent(this);
addAndMakeVisible(menuBar);
}

you’ll need to give it a size in resized or something.

ouch. too wrecked for this![/quote]

hmm my bad, I edited my message and added AddAndMakeVisible in the wrong code block, of course it is in the constructor :stuck_out_tongue:

But finally it works, you were right about the resized thing, without the resize event with a setbound in it, the menubar wasn’t displayed.

Many thanks ! :wink:


#11

woops, last question: is there a way to remove the dropshadow from the menu ?


#12

not sure.

look into

setComponentEffect ( ImageEffectFilter *const newEffect )

on the offending component


#13

I went to a lot of trouble to put those on there!

No way to remove them, but there probably should be. I guess it should be an option in the look-and-feel class.


#14

I went to a lot of trouble to put those on there!

No way to remove them, but there probably should be. I guess it should be an option in the look-and-feel class.[/quote]

I know they are nice, but it doesn’t look really good over a video overlay using directdraw :stuck_out_tongue:


#15

I went to a lot of trouble to put those on there!

No way to remove them, but there probably should be. I guess it should be an option in the look-and-feel class.[/quote]

I know they are nice, but it doesn’t look really good over a video overlay using directdraw :p[/quote]

Ah yes - good point!


#16