Status & Roadmap
Authors & License
Funding Ultimate++
Search on this site
Search in forums

SourceForge.net Logo
Home » U++ Library support » Menus&Toolbars » Minor crash with Menu... [FIXED]
BugFixedDead.gif  Minor crash with Menu... [FIXED] [message #2246] Wed, 05 April 2006 10:32 Go to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member

I've encountered a minor crash situation. In the menu reference example, I changed the code as shown below so that when the menu was clicked, there were no items added to the popup menu. With or without the PromptOK line, clicking on "Menu" then pressing down arrow crashes the app.

	void Menu(Bar& bar)
		bar.Add("Enable numbers", THISBACK(EnableNumbers))
		bar.Add(numbers_enabled, "Numbers", THISBACK(SubMenu));
		bar.Add("Exit", THISBACK(Exit))

I was trying to understand how the menus work and why a sub-menu appears when the Numbers item is clicked - i.e. when the callback to SubMenu occurs, the "calling" code has no idea whether the callback function is going to populate a submenu or not - so the "bar" passed to SubMenu must be a different bar than the one passed to Menu, otherwise the bar.Add in submenu would add on to the original menu instead of creating a new sub-menu.

It seems like every menu callback function has a "bar" passed to it in case it wants to create a sub-menu - is there any other reason for passing bar in the callback?

Anyways, no need for long explanation. It's just a subtlety I'm trying to get my head round.


[Updated on: Wed, 03 May 2006 20:10] by Moderator

Report message to a moderator

Re: Minor crash with Menu [message #2250 is a reply to message #2246] Wed, 05 April 2006 11:09 Go to previous message
mirek is currently offline  mirek
Messages: 12570
Registered: November 2005
Ultimate Member
What a nasty thing you have done to Menu Wink

Now fixed.

And yes, obviously, when submeny pulls, it is another Bar.

MenuBar is derived from Bar and can serve both as toplevel or popup. Popup of submenu is handled in fact by SubmenuBase / SubMenuItem classes and that another MenuBar they have as member...

See MenuBar.cpp, lines 412, 438.

Previous Topic: beginner's questions about menu&bars [SOLVED]+[EXAMPLES]
Next Topic: Menu, SubMenu and Icons [ADDED]
Goto Forum:

Current Time: Fri Jul 03 18:50:47 CEST 2020

Total time taken to generate the page: 0.01635 seconds