Jump to content

Has anyone implemented an intelligent auto scrolling string indicator


Recommended Posts

I'm trying to create an intelligent string display that supports a scroll bar and auto scrolling. The auto scroll is easy. However, what I would like to be able to do is continue to auto scroll as long as the scroll bar is at the bottom. If the user moves the scroll position to something other than the bottom the automatic scrolling will be disabled. Again, this is easy to accomplish. The challenge though is to know when the user has position the scroll bar at the end again so auto scrolling can continue. My string indicator will allow for a fairly large string (10s of thousands of characters) and can contain binary data including the NULL character. The scroll position property is the line number that will appear in the top of the display. However, there doesn't seem to be any way of determining how many lines there are or how many lines the indicator thinks it has. It still has a concept of lines even if there are no actual carriage returns or line feeds in the data.

Has anyone solved this issue? Does anyone have any ideas that may help. I have been struggling with a good way to determine when the user actually moves the scroll bar to the end position. And just to keep this challenging the indicator will be getting automatically updated with new data. I want to allow the user to move the scroll bar and not have the display jump to the bottom again as new data is added. I do however want them to be able to move the scroll bar to the bottom and effectively turn the auto scrolling on again.

Link to comment

Hi Mark,

I created a VI that will count the number of lines in a string indicator.

Number of Lines in String Indicator.vi

The VI below will let you test it out. Currently, when you change the value of the string control, it recalculates the number of lines.

String AutoScroll Main.vi

I tried to test it while resizing the control with the pane, but I need to put some more work into it as it doesn't like the conditions changed on it while it is calculating. I'll add that and send you the VI again.

As for the scroll bar, I'd suggest adding a separate scroll bar as it will give you more control over it and also you can catch the value change event for the scroll bar.

Link to comment

Thanks for the suggestions everyone. Unfortunately simply counting lines is not a solution that will work. In my case I have long strings with no new lines or carriages returns. In addition, if the text wraps in the string indicators what it considers to be the number of lines does not necessary reflect the true number of lines as determined by some end of line character. For example, this paragraph will only have a single end of line character yet within the string indicator it will be seen as multiple lines because of word wrap. If the size of the indicator changes the number of lines also changes. This is a very dynamic number (and somewhat random) in terms of the scroll position. Since I will be updating this display frequently I would like to avoid having to pass it through some line counter VI.

I posted an idea in the LabVIEW Idea Exchange which asked for an auto scroll property built in for scrollable items. Hopefully this would include this functionality as well if they chose to implement it.

If you have any other suggestions I am open to hearing them.

Thanks.

Link to comment

So Mark, how do you AutoScroll when the user moves the scroll bar to the end? If the scroll bar is controlling the scroll position, wouldn't the text automatically followed the scroll bar to the end while you were moving it there?

I guess adding another button at the bottom of the scroll bar could be more intuitive. Here is what I have so far.

Number of Lines in String Indicator.vi

String AutoScroll Main.vi

Can you send me some sample text that you are working with?

Link to comment

Hi Mark,

Now I understand what you meant by moving the scroll bar to the end. I thought that this is a case like reading a large body of text and you wanted it to scroll as the user you read through it. I didn't realize it just had to keep the latest text visible, as it was added, if the scroll bar was moved to the bottom.

Well, I guess now we have two solutions that could help at least two people :)

Link to comment

I'll just throw this out there since I just did it and saw this post:

I initialize a U32 Array (of size 1000) representing the string lengths of every line in the string indicator to length 1. I create a string of 1000 CR constants and store it in a DVR. Every time I concatenate to the log I get the length of the string I'm adding, build it to the length array, chop off the zeroth element of the array, and string subset based on that length.

This approach will NOT limit the string length, but will limit the lines displayed. The scroll will simply stay at the position it was left at, so keep "scrolling." I add some functionality for stopping the "scrolling" by canceling the updates to the display during a mouse down, restarting during mouse up. The actual display updates were performed using a single element queue on a 100 ms timer (lossy enqueue)

I've had success with what I consider a pretty unreasonably large string, I actually made the lines retained smaller because the scrollbar was so unmanageable when trying to go back.

I should also note that this will only work if you know your log postings are one line and one line only. If you want to post a chapter book, best of luck with something else.

Link to comment

Hi Mark,

If keeping the scroll bar position at the bottom is all you need, you do not need to worry about the font or the indicator size.

You just need to (try to) change the scroll position to a crazy large number. It will automatically take the largest value it can. Here's you VI, modified.

Auto Scrolling String Indicator.vi

Link to comment

Thanks Ravi, but your simplified VI does not accomplish what I wanted. As I have stated I want the auto-scroll to keep the scroll bar position at the end of the display as new data comes in. HOWEVER, if the user moves the scroll position up I want to disable the auto scrolling until the user moves the scroll bar pointer back to the end position. And this has to work with data that does not have actual lines. The data my be what is effectively extremely long strings of arbitrary and possibly binary data with no carriage returns or line feeds. The solution I posted above mostly accomplishes this. In the actual application I will be using it I have found a case where I am unable to re-enable the auto-scrolling when I move the pointer back to the bottom.

Link to comment

Don't forget that there is an invoke node to the String control that can "Get Nth Line".

Hi MikaelH, we did use the "Get Nth Line" to count the number of lines, but that takes some iterations (and time) to come up with the number of lines and it didn't work for Mark. His solution works pretty well, where he is calculating number of lines from the font size.

I haven't looked at any VIs in this thread, but if you're not wiring an Inf+ constant for your "crazy large number", you should be. ;)

The Text.ScrollPos property takes in a U32 number that can have a maximum value of xFFFFFFFF or d4294967295, which is the "crazy large number" that we were using.

If you wire Inf+, wouldn't it be converted to the same U32 max of 4294967295?

Link to comment

The Text.ScrollPos property takes in a U32 number that can have a maximum value of xFFFFFFFF or d4294967295, which is the "crazy large number" that we were using.

If you wire Inf+, wouldn't it be converted to the same U32 max of 4294967295?

I'm mostly poking fun ;) The two are functionally equivalent, Inf+ is just pretty and more self-documenting, IMO.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.