From: Chris Ford on 31 Mar 2010 13:08 Hi, I have implemented a uitree in a GUI but am having a slight issue with updating the nodes in the tree. Right now, the only way I can figure out to refresh the nodes is to regenerate the tree entirely, which causes it to collapse down to the initial state (showing only the root node). I would like the tree to stay in its expanded state (whatever that may be) but to have the text and/or icon of a selected node change upon certain actions. For example: My tree is a project explorer that allows the user to navigate through a multi-layered struct type variable. Selecting a field with data in it will display that data to a table. This all works fine. I am trying to add an edit capability, in which the user can select a node in the tree (representing a field in the structure) and click a button to clear the data in that field. Then the tree should update to reflect this, without collapsing. For initializing the tree, I am doing the following: function initializeTree(hObject, eventdata, handles) screenSize=get(0,'ScreenSize'); %Set up navigation tree for new/opened project root = uitreenode('v0','Current Project', handles.projectData.projectInfoStructData.projectName, [], false); tree=uitree('v0','Root',root,'ExpandFcn', {@expfcn_1}); set(tree, 'Units', 'pixels', 'position', ... [screenSize(1,1)+screenSize(1,3)/80 ... screenSize(1,2)+screenSize(1,4)/40 ... screenSize(1,3)-screenSize(1,3)/1.3 ... screenSize(1,4)-screenSize(1,4)/10]) cell_Data = cell(2,1); cell_Data{1} = handles.projectData; set(tree, 'NodeWillExpandCallback', {@nodeWillExpand}); set(tree, 'NodeSelectedCallback', {@nodeSelected,hObject,handles}); tmp = tree.FigureComponent; set(tmp, 'UserData', cell_Data); I could re-set the UserData in tmp (tree.FigureComponent) with the updated handles.projectData whenever it is altered, but I cannot seem to access the tree component from other callbacks that I create. Therefore, as of now I can only recall initializeTree, which replaces the existing tree with a new one with the updated data. This works, but is definitely not ideal from a user standpoint. Any help or suggestions are much appreciated!
|
Pages: 1 Prev: OPC Toolbox Next: matlab - Warning: Infinite or Not-a-Number function value encountered. |