Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
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
Hi

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)
	{
		PromptOK(AsString(234));
		/********
		bar.Add("Enable numbers", THISBACK(EnableNumbers))
		   .Check(numbers_enabled);
		bar.Add(numbers_enabled, "Numbers", THISBACK(SubMenu));
		bar.Add("Exit", THISBACK(Exit))
		   .Key(K_CTRL_E);
		   **********/
	}


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.

Graeme

[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: 13975
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.

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


Current Time: Thu Mar 28 12:21:38 CET 2024

Total time taken to generate the page: 0.01044 seconds