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 » Embed editfields in ArrayCtrl
Re: Embed editfields in ArrayCtrl [message #24276 is a reply to message #24275] Fri, 08 January 2010 15:28 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mrjt wrote on Fri, 08 January 2010 08:49

Except it doesn't work at all! Razz

The problems:
- EditField doesn't have StdBar, are you thinking of EditText?



May I suggest you update your U++ from time to time? Smile (was added 2-3 months back).

Quote:


- As above for WhenMenu, just overload RightDown and call EditField::DoMenu



Means EditField::RightDown does not get called...

Quote:


- I've also changed it to use ArrayCtrl::StdBar and set the ArrayCtrl cursor correctly to enable this, which is more in line with the way the ArrayCtrl works.



That one is a good idea. I had these left because of experimenting with another solution. So:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct EditStringSpecial : EditString {
	ArrayCtrl *GetArrayCtrl() {
		for(Ctrl *q = GetParent(); q; q = q->GetParent())
			if(ArrayCtrl *a = dynamic_cast<ArrayCtrl *>(q))
				return a;
		return NULL;
	}
	
	static void DoMenu(EditStringSpecial *x) {
		MenuBar bar;
		x->StdBar(bar);
		ArrayCtrl *a = x->GetArrayCtrl();
		if(a) {
			bar.Separator();
			a->WhenBar(bar);
		}
		bar.Execute();
	}

	void MyBar(Bar& bar)
	{
		PostCallback(callback1(DoMenu, this));
	}

	typedef EditStringSpecial CLASSNAME;

	EditStringSpecial() {
		WhenBar = THISBACK(MyBar);		
	}
};

GUI_APP_MAIN
{
	ArrayCtrl a;
	a.Appending().Removing();
	a.AddColumn("Text").Ctrls<EditStringSpecial>();
	for(int i = 0; i < 300; i++)
		a.Add(AsString(i));
	a.SetLineCy(Draw::GetStdFontCy() + 8);

	TopWindow app;
	app.Add(a.SizePos());
	app.Sizeable();
	app.Run();
}


Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: problems with ArrayCtrl and SetFont
Next Topic: Assertion in GridCtrl
Goto Forum:
  


Current Time: Sat Apr 27 01:19:34 CEST 2024

Total time taken to generate the page: 3.12757 seconds