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 » Creating sub menus without callback functions
Re: Creating sub menus without callback functions [message #5908 is a reply to message #5901] Tue, 24 October 2006 13:09 Go to previous messageGo to previous message
prog13 is currently offline  prog13
Messages: 2
Registered: October 2006
Junior Member
Ok thanks for the reply, I'm now saving the whole menu structure in a tree container and then using callbacks on that. It works now, although I had to work around THISBACK2(...)/callback2(...) using a helper struct. THISBACK2 doesn't seem to work (v610) - at least in this context. To verify this I modified the menu reference example:
	void SubMenu(Bar& bar, int a, int b)
	{
		for(int i = 0; i < 10; i++)
			bar.Add(AsString(i), THISBACK1(ShowNumber, i));
	}
	

	void Menu(Bar& bar)
	{
		bar.Add("Enable numbers", THISBACK(EnableNumbers))
		   .Check(numbers_enabled);
		bar.Add(numbers_enabled, "Numbers", THISBACK2(SubMenu,1,2));
		bar.Add("Exit", THISBACK(Exit))
		   .Key(K_CTRL_E);
	}


This gives the following compiler errors:

MSVC8:
C:\upp\reference\Menu\menu.cpp(33) : error C2780: 'Callback callback2(Callback2<P1,P2>,T1
	,T2)' : expects 3 arguments - 4 provided
        C:\upp\uppsrc\Core/Callback.h(202) : see declaration of 'callback2'
C:\upp\reference\Menu\menu.cpp(33) : error C2780: 'Callback callback2(R (__cdecl *)(A,B),
	T1,T2)' : expects 3 arguments - 4 provided
        C:\upp\uppsrc\Core/Callback.h(197) : see declaration of 'callback2'
C:\upp\reference\Menu\menu.cpp(33) : error C2784: 'Callback callback2(const Object *,R (_
	_thiscall O::* )(A,B) const,T1,T2)' : could not deduce template argument for 'R (__th
	iscall O::* )(A,B) const' from 'void (__thiscall App::* )(Bar &,int,int)'
        C:\upp\uppsrc\Core/Callback.h(181) : see declaration of 'callback2'
C:\upp\reference\Menu\menu.cpp(33) : error C2784: 'Callback callback2(Object *,R (__thisc
	all O::* )(A,B),T1,T2)' : could not deduce template argument for 'R (__thiscall O::* 
	)(A,B)' from 'void (__thiscall App::* )(Bar &,int,int)'
        C:\upp\uppsrc\Core/Callback.h(175) : see declaration of 'callback2'

GCC(MinGW):
C:\upp\reference\Menu\menu.cpp: In member function `void App::Menu(Bar&)':
C:\upp\reference\Menu\menu.cpp:33: error: no matching function for call to `callback2(App
	* const, void (App::*)(Bar&, int, int), int, int)'


Despite this working for me now and most smaller applications wouldn't read their interfaces from a file at runtime anyways, I think it might be worth it to allow for a more "procedural" approach of menu creation for such situations - I haven't investigated the needed changes, so it could be too much work for the benifit.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DropList bug
Next Topic: MenuBar.Execute seems to ignore owner - Bug?
Goto Forum:
  


Current Time: Mon Aug 18 15:13:36 CEST 2025

Total time taken to generate the page: 0.05974 seconds