Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTree Vertical Scrolling

Status
Not open for further replies.

bgreenhouse

Technical User
Feb 20, 2000
231
CA
Hi Folks

This is a little complicated, but I'll try to whittle it down. I've got a Ftree component set up, and I use setSelectedNode() to set which node is shown as selected. If there's a list of nodes that's long enough to require vertical scrolling, and I set a node below the lower edge of the window - you have to scroll down to see which node is selected. I want it to be done automatically.

I know how to set the vertical scroll position in a scrollPane, but I'm not sure how to go about doing this in the FTree component - I thought (hoped) it would do it automatically when I set a certain node to be selected.

Any thoughts?

Thanks,

Ben
 
I have never tried this so no idea if it will work, but the tree does have refresh functions. This one at line 580 looks promising

FTreeClass.prototype.updateControl = function(skipInitSB) {
if(this.getLength() <= this.numDisplayed) {
this.topDisplayed = 0;
}
for (var i=0; i<this.numDisplayed; i++) {
this.container_mc[&quot;fListItem&quot; + i + &quot;_mc&quot;].drawItem(this.getItemAt(this.topDisplayed + i), this.isSelected(this.topDisplayed+i));
}
if(skipInitSB == undefined || (this.hsb_mc == undefined && this.needHS())) {
this.initScrollBar();
}
}

you might want to try adding a scroll update to this function
 
Hi Bill

Thanks for all your help! I'm trying to decipher their code - do you know what they mean when they reference this.cn? I can't figure out what they're talking about.

Any ideas?

Thanks

B
 
Hey Bill

I've got a little farther on this one. The vertical scrollbar inside the FTree component is referred to by
Code:
treename.sbc_mc.sb_mc
, so I can just do a
Code:
setScrollPosition()
on that. Now I'm trying to figure out a way to determine the proper height it should scroll to. I looked at properties of the nodes, but couldn't find anything. I was thinking there might be some sort of &quot;number&quot; that it is in the list, and then I could just set the height of the scrollbar to that number multiplied by an approximation of line height and that would probably work fine. Any idea where I could get a property like that?

Thanks,

B
 
I may just be rambling but there ought to be a way to determine the line number of the selected node and then tie that in to the scroll position.
If I get some time over the weekend I will look into that possibility and see if i can develop it further.
 
Hey Bill

Thanks for all your help, I figured it out! Reading through the Ftree Component's code, I found that there's a private method called &quot;getSelectedIndex();&quot;. I just run the following code, and it works like a charm...

Code:
num_index = _root.mc_index.index_tree.getSelectedIndex();
_root.mc_index.index_tree.sbc_mc.sb_mc.setScrollPosition(num_index);

Hope someone else gets through this faster because of this topic!!!

Thanks again,

Ben
 
excellent well done.....shows the benefit of examining component code
i am currently struggling with building my version of a combo box from scratch...the mm one lacks features i want and cant be fulled adpted to meet requirements
i shall give you a shout when i get stuck down a blind alley.
 
If I can be of any help, let me know. Maybe answer to this thread since I have email notification on - direct me to the new thread or whatever. Hopefully you won't get stuck down any blind alleys!

B
 
Hey Bill

I hope you're still listening...Beta Testing of this project has turned up a strange problem. I'll try to explain as best I can, unfortunately I can't post a link since the client doesn't want the site public yet...If you remember, I have a .swf that is split into two sections. On the right is a &quot;content window&quot; where information on a specific topic is displayed, and on the left is an index made with the FTree component. There is also a combo box on the left that lets you get different types of views of the index. Anyway, I have set it up so that you can open the .swf with a specific topic already in the &quot;content window&quot; by passing an id number through the URL. In order to keep the navigation constant, I've set up some code that selects the proper entry in the index on the left. Then, I made a function that scrolls the Ftree down to the appropriate level, that was mentioned above.

Okay! That's the background. Now here's the strange problem...Two of the four possible views of the index tree (selected from the combo box) have sub folders in the tree, so there aren't initially leaves when the &quot;view&quot; is opened, instead there are sub folders.

Now, the &quot;view&quot; that is initially selected has no subfolders, the entries are visible as leaves right away.

Now, this is hard to explain, but listen carefully ;o) - if you select a view that has subfolders, there are folders missing from the tree equivalent to the number of entries down the original index item was...That's not clear so let me give you an example. If the original index entry was the first one in the list, when you select a &quot;view&quot; with subfolders, the first subfolder is missing. If the original index was the second down, the first two are missing and so on until you get to where the original entry is farther down the list than the total number of sub folders and all are missing. If you just click again on teh combo box it all works out, but it's a definite bug.

I'm sure I've made no sense here, and I apologize for it being so long...Any hints anyone?

B
 
If the original index entry was the first one in the list, when you select a &quot;view&quot; with subfolders, the first subfolder is missing

What does it say in debug when you look there for that missing subfolder ?
 
Unfortunately, the Debugger crashes due to the amount of XML data that's flowing in...Maybe I should write the guy who made the FTree component and ask his advice on a scroller...

B
 
Thanks Bill

This one actually works off 4 arrays that I build from one XML document that contains all the data. I'd have to redo all my xml to make it work with the XML Tree component. I've gone through my index and made a &quot;short&quot; version that doesn't mess up the debugger. As far as I can tell it doesn't change the data provider or the array. I put a little button on the stage that refreshes the index when you click it. Any time you click on that button it automatically fixes the problem. I don't what that tells me, but I know it tells me something. I've tried putting refresh statements all around the code in various places, but haven't come up with anything yet...

Any more suggestions?

B
 
Alright, I've figured out a crude fix...For anyone who's read this far, I think it's a bug so good luck with it. My fix is as follows:

Code:
var intervalID;
i = 0;
function resetindex(){
	_root.mc_index.index_tree.refresh();
	i += 1;
	if (i>10){
		clearInterval(intervalID)
	}
}
intervalID = setInterval(resetindex, 100);
}

As I mentioned before, if I put a button on the stage that refreshed the index, it would display fine, but I couldn't figure out where to put a refresh in the as code. I tried everywhere.

This is part of the on change handler, so that when the index is changed, the setInterval runs the &quot;resetindex&quot; function every 100 milliseconds for 11 times. This ensures that the index gets refreshed at least a second after the index is loaded. It looks to me like it fixes it in the first interval, but I'm too tired to whittle it down and test it on a ton of computers...

Hope this helps someone! I got intimately familiar with the FScrollBarClass and FTreeClass code if that's any consolation...

B

B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top