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 » TreeCtrl » Anomaly in tree control
Anomaly in tree control [message #29781] Tue, 16 November 2010 11:38 Go to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
I just noticed what seems to be a problem in the tree control. I was trying the tree control reference example and with the tree showing a directory I was testing to see whether the tree remembered the collapsed/ uncollapsed state of lower level nodes when the top level node was uncollapsed -> collapsed -> uncollapsed. I found the lower level plus/minus icon then showed as uncollapsed (minus) but the node wasn't actually expanded.
i.e.
start with tree all collapsed
use right arrow key to expand first level
use down arrow key to go to first child
use right arrow key to expand first child
use up arrow key to go back to root node
use left arrow key to collapse root node
use right arrow key to expand root node

now you should see the problem where the first child node has a minus icon but is uncollapsed. Sometimes the problem doesn't appear the first time.

Graeme
Re: Anomaly in tree control [message #29782 is a reply to message #29781] Tue, 16 November 2010 11:43 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Is this not a specific problem with that example? If I remember correctly it creates the entries for sub-trees on demand (when you click the plus) and removes then when it's closed. Therefor it will not remember the openness of nested trees.

I'm pretty sure it works correctly for more normal situations.
Re: Anomaly in tree control [message #29783 is a reply to message #29782] Tue, 16 November 2010 11:57 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I does appear to be a bug. The TreeCtrl uses a pool of nodes to reduce allocation times but doesn't reset Node::isopen on a new Insert. In this case that means that the node thinks it's open but iot doesn't have a sub-tree because the WhenOpen callback hasn't been triggered.

The additon of:
m.isopen = false;

to TreeCtrl::Insert fixes the problem.

This example will still not be able to remember the openness of nest trees though. If you want dynamic sub-tree creation while remembering the opneness of sub-trees you'll have to remember fodler states yourself.

[Updated on: Tue, 16 November 2010 11:58]

Report message to a moderator

Re: Anomaly in tree control [message #29784 is a reply to message #29782] Tue, 16 November 2010 12:00 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
Not sure.
close directory in the example is this

void CloseDir(int id) {
tree1.RemoveChildren(id);
}

I changed it to this but it didn't fix the problem

void CloseDir(int id) {
tree1.Close(id);
tree1.RemoveChildren(id);
}

so I guess the minus sign is showing there's no children.
I'm wondering if there should be no plus or minus icon on a node that has no children - but then for this example you wouldn't be able to re-populate the node so perhaps remove-children isn't quite the normal thing to do in CloseDir.

[Edit] - oops, didn't see your second answer before I posted this. Thanks.

[Updated on: Tue, 16 November 2010 12:02]

Report message to a moderator

Re: Anomaly in tree control [message #29974 is a reply to message #29783] Wed, 01 December 2010 19:40 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mrjt wrote on Tue, 16 November 2010 05:57

m.isopen = false;

to TreeCtrl::Insert fixes the problem.



Thanks, patch applied.
Previous Topic: Basic query: id, key and value in a TreeCtrl.
Next Topic: Changing tree control style
Goto Forum:
  


Current Time: Thu Mar 28 19:27:29 CET 2024

Total time taken to generate the page: 0.01076 seconds