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 » [bug?] Can't Convert::Scan rows in ArrayCtrl
[bug?] Can't Convert::Scan rows in ArrayCtrl [message #42717] Mon, 31 March 2014 00:17 Go to previous message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Hi, there!

Method MyConv::Scan never gets called when running code case below:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyConv : Convert
{
	Value Scan(const Value& text) const
	{
		return "returning whatever I want!";
	}
};

class App : public TopWindow
{
	public:
	typedef App CLASSNAME;
	
	App()
	{
		Add(arr.SizePos());
		arr.AddColumn("some column").SetConvert(Single<MyConv>());
		for(int i = 0; i < 10; i++)
			arr.Add(Format("double click here - %d", i));
		arr.WhenLeftDouble = THISBACK(DDClick);
	}
	
	void DDClick()
	{
		PromptOK(arr.Get(0).ToString());
	}
	
	ArrayCtrl		arr;
};

GUI_APP_MAIN
{
	App().Run();
}


Isn't Convert::Scan all about 'returning whatever I want' into my PromptOK? Well, it doesn't! It just relays unchanged row content after double clicking it.
After poking around for a while, I ended up inserting the following patch in ArrayCtrl.cpp near line #336:

	for(i = 0; i < control.GetCount(); i++) {
		const Control& c = control[i];
		if(Pos(c.pos) == ii)
			return c.ctrl->GetData();
	}
	const Column& m = column[ii];                      // <- patched
	if(m.convert)                                      // <-- patched
		return m.convert->Scan(Get0(cursor, ii));  // <-- patched
	return Get0(cursor, ii);


Now it works as (I) expected!

Comments?

Tks!!
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: [BUG & FIX] in HeaderCtrl::LeftDouble
Next Topic: GridCtrl sorting
Goto Forum:
  


Current Time: Fri Mar 29 12:05:10 CET 2024

Total time taken to generate the page: 0.01612 seconds