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 » Popup menu with check items
Popup menu with check items [message #39245] Mon, 04 March 2013 11:37 Go to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

I need a small popup menu with some items used to change a bool value, and showing a check box at their left.

This is working very well with submenus, but I cannot find a way to have it working in the main menu... In other words :

MainMenu > v CheckItem1
           v CheckItem2
             OtherItem

is working well, but not the simple (main) menu
v checkItem1
v checkItem2
  otherItem


Is there a way to have it working ?

Thanks.
Re: Popup menu with check items [message #39251 is a reply to message #39245] Tue, 05 March 2013 20:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
jibe wrote on Mon, 04 March 2013 05:37

Hi,

I need a small popup menu with some items used to change a bool value, and showing a check box at their left.

This is working very well with submenus, but I cannot find a way to have it working in the main menu... In other words :

MainMenu > v CheckItem1
           v CheckItem2
             OtherItem

is working well, but not the simple (main) menu
v checkItem1
v checkItem2
  otherItem


Is there a way to have it working ?

Thanks.


Should be the same (except top-level menu). What is the problem? (Show us the code..)
Re: Popup menu with check items [message #39267 is a reply to message #39245] Thu, 07 March 2013 08:49 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

Sorry for the bad place and thanks for moving.

Seeing that my code was not working, I just had a try changing the "Menu" in the reference samples. Here are the changed parts :
void MainBar(Bar& bar)
{
	bar.Add("Menu", THISBACK(Menu));
	bar.Add("Enable numbers", THISBACK(EnableNumbers)).Check(numbers_enabled); // *** Added ***
}

void RightDown(Point p, dword keyflags)		 // *** Added ***
{						 // *** Added ***
	menu.PopUp();				 // *** Added ***
}						 // *** Added ***

MenuBar menu;
	typedef App CLASSNAME;

App()
{
	numbers_enabled = false;
	//AddFrame(menu);			 // *** Commented ***
	menu.Set(THISBACK(MainBar));
}


This way, I have no more menu bar, and a popup with the EnableNumbers option both in the menu and in the submenu. It is working well in the submenu, but not in the menu...

Am I doing something wrong ?

BTW, I'm trying this under Ubuntu, Theide/Upp version 5858.
Re: Popup menu with check items [message #39268 is a reply to message #39251] Thu, 07 March 2013 08:59 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
mirek wrote on Tue, 05 March 2013 20:20

Should be the same (except top-level menu).

Ooops... Didn't pay attention to this...

Does this mean that it's normal that it does not work in the top-level menu ?

My problem is that I need just one level (that is often the case with a popup), so I have only a top-level menu...

I'm a little confused... How to do to have no menu bar, and only a one-level popup menu ? What is the difference between top-level menu and submenus ?
Re: Popup menu with check items [message #39269 is a reply to message #39268] Thu, 07 March 2013 09:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyApp : TopWindow {
	typedef MyApp CLASSNAME;

	bool check;

	void Check() { check = !check; }

	void RightDown(Point p, dword) {
		MenuBar bar;
		bar.Add("Check", THISBACK(Check)).Check(check);
		bar.Execute();
	}
	
	MyApp() {
		check = false;
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}
Re: Popup menu with check items [message #39274 is a reply to message #39245] Thu, 07 March 2013 18:32 Go to previous message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

Ok, thanks Smile

Maybe this could be added to the reference sample, so that people don't make the same mistake as me Wink
Previous Topic: ToolBar Callback weirdness
Next Topic: [Minor bug & fix] Wrong color of MenuBar item when mouse cursor is on it (Gtk backend)
Goto Forum:
  


Current Time: Thu Mar 28 20:00:35 CET 2024

Total time taken to generate the page: 0.02009 seconds