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 next 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!!
Re: [bug?] Can't Convert::Scan rows in ArrayCtrl [message #43163 is a reply to message #42717] Fri, 23 May 2014 12:40 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Hey, Upp people?

Again, what's Scan for? How to use it?

Tks!!
Re: [bug?] Can't Convert::Scan rows in ArrayCtrl [message #43405 is a reply to message #42717] Fri, 25 July 2014 14:55 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
I hear crickets...

[Updated on: Sun, 27 July 2014 22:08]

Report message to a moderator

Re: [bug?] Can't Convert::Scan rows in ArrayCtrl [message #43479 is a reply to message #42717] Sat, 09 August 2014 10:15 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Nope, ArrayCtrl always uses only Format.

Scan (and Filter) is meant for input fields (EditField) or similiar situations.

I think you can describe situation as

- Format is usually meant to convert some original Value to some readable output.
- Scan is meant to convert this readable output back to original Value

Now ArrayCtrl stores (usually) original Values. What you expected it to do is to convert this original Value to... what? another original Value?

Another argument is that you can easily convert Value stored in ArrayCtrl to any other Value easily (e.g. in DDClick).

Mirek
Previous Topic: [BUG & FIX] in HeaderCtrl::LeftDouble
Next Topic: GridCtrl sorting
Goto Forum:
  


Current Time: Fri Apr 19 04:20:55 CEST 2024

Total time taken to generate the page: 2.08509 seconds