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 » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl: how to identify embeded Option
ArrayCtrl: how to identify embeded Option [message #60647] Thu, 20 June 2024 10:04 Go to next message
forlano is currently offline  forlano
Messages: 1207
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

this is related to a previous not yet answered post. The eventual answer to this one indirectly solve even the other.

I need to put about 40 Option in an ArrayCtrl. When checked each Option should activate a callback that:

1. recognise which Option has been pressed;
2. can get the status (checked/unchecked) of that Option.

Which is the best way to embed the Option in the ArrayCtrl? How to declare the callback that pass the relevant info to perform the previous tasks?
At moment I solve the task 2 in an ugly manner via a lookup table and then look at the Option position in the ArrayCtrl, But I am sure there is a better way to do it.

Thanks,
Luigi

[Updated on: Thu, 20 June 2024 10:44]

Report message to a moderator

Re: ArrayCtrl: how to identify embeded Option [message #60648 is a reply to message #60647] Thu, 20 June 2024 10:42 Go to previous message
forlano is currently offline  forlano
Messages: 1207
Registered: March 2006
Location: Italy
Senior Contributor
Here is the solution after the Victor's example

https:// www.ultimatepp.org/forums/index.php?t=msg&th=12293&g oto=60649&#msg_60649

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct Test : TopWindow {
	ArrayCtrl ar;
	
	void AddOption(int row, int col, int idOpt) {
		Option& opt = ar.CreateCtrl<Option>(row,col,false);
		opt << [&,idOpt] {
			Exclamation(Sprintf("Pressed Option: ID = %d , status = %d", idOpt, opt.Get()));
		};
	}
	
	Test() {
		SetRect(0, 0, 640, 480);
		Add(ar.SizePos());
		ar.AddColumn("Col 1", 1);
		ar.AddColumn("Col 2", 1);
		ar.AddColumn("Col 3", 1);
		for (int i=0; i<10; ++i) ar.Add(i);
		AddOption(0, 1, 100);
		AddOption(1, 2, 101);
		AddOption(2, 1, 102);
		AddOption(3, 2, 103);
		AddOption(4, 1, 104);
		AddOption(5, 2, 105);
		AddOption(6, 1, 106);
		AddOption(7, 2, 106);
	}
};

GUI_APP_MAIN {
	Test().Run();
}

[Updated on: Thu, 20 June 2024 13:20]

Report message to a moderator

Previous Topic: GridCtrl: how to center Option?
Next Topic: ArrayCtrl: how activated a callbak by an embedded Option
Goto Forum:
  


Current Time: Fri Jun 13 13:45:01 CEST 2025

Total time taken to generate the page: 0.04983 seconds