Home » U++ Library support » TreeCtrl » OptionTree loses check state
OptionTree loses check state [message #24445] |
Mon, 18 January 2010 00:53  |
galious
Messages: 28 Registered: March 2008
|
Promising Member |
|
|
Hi,
when dynamically adding childs to a node in a OptionTree the check state of the both the childs and the parent is lost. E.G. using the code provided below try to tick on the root node (while it is still collapsed) and after expanding no checkbox will be ticked on.
I didn't expect this behaviour and so changed it in the UPP code:
in TreeCtrl.cpp
int OptionTree::Insert(int parentid, int i, const Image& img, const char *text)
{
return Insert(parentid, i, img, aux.Add().Set(option[parentid]->Get()).NoNotNull(), text);
}
int OptionTree::Insert(int parentid, int i, const char *text)
{
return Insert(parentid, i, aux.Add().Set(option[parentid]->Get()).NoNotNull(), text);
}
and to provide the chaining behaviour in Button.cpp (and of course I changed the declaration to):
Option& Option::Set(int b) {
if(b != option) {
option = b;
Update();
RefreshPush();
}
return *this;
}
Finally the code I tested with:
#include "CtrlLib/CtrlLib.h"
using namespace Upp;
struct App : TopWindow {
OptionTree tree;
typedef App CLASSNAME;
void OpenDir(int id) {
String path = tree.GetLabel(id);
for(FindFile ff(AppendFileName(path, "*.*")); ff; ff.Next()) {
String n = ff.GetName();
if(n != "." && n != ".." && ff.IsFolder()) {
int childId = tree.Add(id, AppendFileName(path, n));
tree.SetNode(childId, tree.GetNode(childId).CanOpen(true));
}
}
}
void CloseDir(int id) {
tree.RemoveChildren(id);
}
App() {
Add(tree.SizePos());
tree.WhenOpen = THISBACK(OpenDir);
tree.WhenClose = THISBACK(CloseDir);
#ifdef PLATFORM_WIN32
String dir = String(GetExeFilePath()[0], 1) + ":\\";
#else
String dir = "/usr";
#endif
tree.SetRoot(dir);
tree.Set(0, dir);
Sizeable();
}
};
GUI_APP_MAIN
{
App().Run();
}
Is it possible to include this change (at the least changed behaviour) in UPP?
Best regards,
Martin Schut
|
|
|
Goto Forum:
Current Time: Wed May 14 16:49:31 CEST 2025
Total time taken to generate the page: 0.00988 seconds
|