Home » U++ Library support » TreeCtrl » Bug changing text after node insertion
|
|
|
|
|
|
| Re: Bug changing text after node insertion [message #16860 is a reply to message #16859] |
Thu, 17 July 2008 17:57   |
cbpporter
Messages: 1428 Registered: September 2007
|
Ultimate Contributor |
|
|
Thank you masu for investigating. Still, removing nodes and adding then is much more complicated that it should be and doesn't address the problem directly.
Mirek's function would solve the problem but from a purist point of view it doesn't make that much sense. Nodes do not logically have a label property. If we accept setting the label as a valid operation, than what is the difference between setting the label and setting the key. Are both operations defined? Can you mix them? If you mix them can you get a combination that results in two labels again? And why does adding a node behave differently than setting the node to a different value?
Shouldn't we rather add SetKey/SetValue functions, or just Set variant for both, as in Node and other cases? Anyway, which value is the key and which is the values and which is passed to Display/Converts is not too clear.
[Updated on: Thu, 17 July 2008 17:57] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Bug changing text after node insertion [message #16923 is a reply to message #16921] |
Mon, 21 July 2008 10:23   |
cbpporter
Messages: 1428 Registered: September 2007
|
Ultimate Contributor |
|
|
It is getting closer. There is still a problem as you can see in this screenshot I created. The text is diplayed once for the label and once for the key/value. It seems to display the value.
I'm using SetLabel, and also the normal Set to set key and value. I also use a modified version of Copy to repopulate another tree with the checked items of this tree.
int CopyIfSelected(TreeCtrl& dst, int did, const OptionTree& src, int id)
{
TreeCtrl::Node x = src.GetNode(id);
x.ctrl = NULL;
int orig = did;
if (src.Get(id))
did = dst.Add(did, x);
dst.Open(orig);
for(int i = 0; i < src.GetChildCount(id); i++)
CopyIfSelected(dst, did, src, src.GetChild(id, i));
return did;
}
When I use Set, the first parameter is a struct and the second one is the string that I display. Swapping these around or leaving out the second string parameter will clear the extra text that appears in the right, but the are is still clickable, leaving a small little gray rect when clicked. I could live with that for now, but both swapping the parameters or leaving one out will render my CoyIfSelected function useless, because it will not set the text in the destination Tree.
|
|
|
|
| Re: Bug changing text after node insertion [message #16924 is a reply to message #16923] |
Mon, 21 July 2008 10:43   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
| cbpporter wrote on Mon, 21 July 2008 04:23 | It is getting closer. There is still a problem as you can see in this screenshot I created. The text is diplayed once for the label and once for the key/value. It seems to display the value.
I'm using SetLabel, and also the normal Set to set key and value. I also use a modified version of Copy to repopulate another tree with the checked items of this tree.
int CopyIfSelected(TreeCtrl& dst, int did, const OptionTree& src, int id)
{
TreeCtrl::Node x = src.GetNode(id);
x.ctrl = NULL;
int orig = did;
if (src.Get(id))
did = dst.Add(did, x);
dst.Open(orig);
for(int i = 0; i < src.GetChildCount(id); i++)
CopyIfSelected(dst, did, src, src.GetChild(id, i));
return did;
}
When I use Set, the first parameter is a struct and the second one is the string that I display. Swapping these around or leaving out the second string parameter will clear the extra text that appears in the right, but the are is still clickable, leaving a small little gray rect when clicked. I could live with that for now, but both swapping the parameters or leaving one out will render my CoyIfSelected function useless, because it will not set the text in the destination Tree.
|
I guess we will need GetLabel too....
Mirek
|
|
|
|
|
|
|
|
| Re: Bug changing text after node insertion [message #16927 is a reply to message #16926] |
Mon, 21 July 2008 12:36   |
cbpporter
Messages: 1428 Registered: September 2007
|
Ultimate Contributor |
|
|
| luzr wrote on Mon, 21 July 2008 12:52 |
Ehm, but it is not a double text... These are different things, the label is an attribute of widget... Widget can have more than one attributes.
OK, one possible solution would be to supress the "value" when ctrl is set for the node.
Mirek
|
I know that the two text are from different sources, one is the label of the Option and the other is the value painted on the control (with a huge space between then, probably because of the Width of the Option), but still by my definition if there are two text (doesn't matter why), that constitutes a double text .
Yes, suppressing it and moving the region in which when you click an item it will be highlighted with a dotted rect so that it encapsulates the Option would probably work.
| Quote: |
OTOH I believe that current solution when both are used is in fact more general.
|
I'm not sure I understand. What is current solution? Or do you mean solution as in the way things work right now, not "solution to my problem".
|
|
|
|
|
|
|
|
|
|
| Re: Bug changing text after node insertion [message #16932 is a reply to message #16930] |
Mon, 21 July 2008 14:56   |
cbpporter
Messages: 1428 Registered: September 2007
|
Ultimate Contributor |
|
|
I guess we have different representations on what a tree control should do.
Maybe it would be better for me to find a different solution rather than tweak OptionTree to suit my needs, since it seems that it was built with other needs in mind.
Also, I think there is something broken with MINGW debugger. I download RC2 today and debugging doesn't work for me. It was always a little buggy under MINGW, but it was usable. But now, break points are sometimes ignored step in and over don't work at all.
[Updated on: Mon, 21 July 2008 14:56] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Bug changing text after node insertion [message #16958 is a reply to message #16954] |
Wed, 23 July 2008 10:53   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
| luzr wrote on Wed, 23 July 2008 09:10 |
Partial solution is to not use Option's Label (leave it empty) and put its text to Node's Value (haha, back at it again . Then clicking the option box will toggle the option, clicking the text will do selections.
|
You have to do it like this anyway, otherwise the Option obscures the highlight rect.
| Quote: | I am afraid this might not be consistent with interface behaviour e.g. in case there are EditFields in the TreeCtrl...
|
To be honest I think it makes as much sense as anything else in that situation, and it will only change behaviour when using multiselect and ctrls.
The existing way, where the current selection is cleared whenever a ctrl gets focus is broken. For instance, currently the selection is cleared if focus changes to another window then back again.
| Quote: |
What makes me wonder, BTW, is how the Option gets the focus?!
|
The sequence is:
LeftDown
DoClick
SetCursorLine
SetWantFocus on the ctrl
ChildGotFocus
SetCursorLine
SelectOne (obviously clears any other selected items)
Perhaps a better solution would be to stop the first CursorLine being called when using CTRL-key and multiselect, but the behaviour is definitely wrong.
|
|
|
|
|
|
|
|
| Re: Bug changing text after node insertion [message #17006 is a reply to message #16963] |
Thu, 24 July 2008 22:44   |
cbpporter
Messages: 1428 Registered: September 2007
|
Ultimate Contributor |
|
|
| cbpporter wrote on Wed, 23 July 2008 14:45 |
I'll leave it as it is for now, because there are other strange behaviors that I didn't find a reason for yet. Getting the changed checked status of a item in the OptionTree that is not checked doesn't seem to work only after it has been changed. I'll investigate these and if they'll look like a bug, I'll post about them. I hope they are just some mistake of mine.
|
False alarm, it was my fault. My old friend: initialized class members... I wish C++ would warn me about this one. Or maybe we could add it later to the new C++ parser.
| cbpporter wrote on Wed, 23 July 2008 14:45 |
I'm not going back to that again .
|
Well I did and after a lot of work I pretty much got what I wanted. There are still some display issues, like strange background color and unaligned focus rect, but I can fix those. Still, this is almost the most (unnecessarily) complicated part of the whole program .
But for it to work as expected, one of the previous fixes must be reverted:
TreeCtrl::Node::Node(const Image& img, Ctrl& ctrl, int cx, int cy)
{
Init();
SetCtrl(ctrl);
image = img;
size = Null;
if(cx > 0)
size.cx = cx;
if(cy > 0)
size.cy = cy;
}
With this fix, there is that huge cap between Option (which now has no text) and text displayed by tree. If we undo it, they will be side by side again.
|
|
|
|
| Re: Bug changing text after node insertion [message #19010 is a reply to message #17006] |
Wed, 05 November 2008 10:07   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
| cbpporter wrote on Thu, 24 July 2008 16:44 |
False alarm, it was my fault. My old friend: initialized class members...
|
Hehe, I always do the same mistake too.
In fact, I really would not be sorry if C++ default initialized to 0...
| Quote: |
TreeCtrl::Node::Node(const Image& img, Ctrl& ctrl, int cx, int cy)
{
Init();
SetCtrl(ctrl);
image = img;
size = Null;
if(cx > 0)
size.cx = cx;
if(cy > 0)
size.cy = cy;
}
If we undo it, they will be side by side again.
|
Ehm, and what is the correct version then? 
Mirek
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sun Apr 26 16:27:11 GMT+2 2026
Total time taken to generate the page: 0.01134 seconds
|