uitree cannot expand subdirectories when trailing filesep is missing.

2 views (last 30 days)
I know that uitree is unsupported, but I thought it would be good to let you guys know about this bug anyways.
I have found a workaround already, so this is not really a question but a source of information for others. If this is not rhe right place for such a thing, please move it where it belongs.
Problem:
uitree cannot expand subdirectories when trailing filesep is missing.
I am using matlab version 2014b
Example (on a mac):
Folder tree:
/Users/foo/
bar/
subbar1/
subbar2/
bas/
Matlab code to reproduce problem:
mtree=uitree('v0','root','/Users/foo');
node=mtree.Root.getChildAt(0);
mtree.expand(node);
node.getChildCount
ans = 0
The reason can be seen with
node.getValue
ans =
/Users/foobar/
Note that the slash between foo and bar is missing (the path has been f* up beyond all recognition ;-).
Workaround:
If I call uitree with a trailing slash in the path, everything works fine:
mtree=uitree('v0','root','/Users/foo/');
node=mtree.Root.getChildAt(0);
mtree.expand(node);
node.getChildCount
ans = 2
node.getValue
ans =
/Users/foo/bar/

Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!