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:
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).