10-02-2012 12:08 PM
Hi. I came across this when perusing Darren's Nuggets list (prompted from today's NI Newsletter email I received). I played with it a little and came up with the following:
First I had an Auto Scroll check box, but it is not being used now. Instead I'm using the String KeyFocus property to turn "auto-scroll" off and on. When the user clicks in the string control (on the scroll bar does not set the KeyFocus), KeyFocus is set to true which turns auto scroll off. Now the user can drag the scroll bar to view prevous text. KeyFocus stays true even while the user is clicking and dragging the scroll bar. The user must click completely out of the String indicator for KeyFocus to be set false, which turns "auto-scroll" back on. (I also added the space in the format string to after the number rather than before as Darren had so the first item in the string indicator does not have a leading space. I also cleared the string indicator upon startup.) (The String Text.ScrollPosition indicator is just for my debugging.)
This is much simpler than some other solutions like this one: https://decibel.ni.com/content/docs/DOC-1298
It would be nice if the next version of LabVIEW would make this automatic when grabbing any scroll bar. There are many old applications, such as Free Serial Port Monitor (2003), that do this.
Cheers!
09-25-2013 03:42 AM - edited 09-25-2013 04:09 AM
I too had the needs for implementing a console window and intelligent autoscrolling was something that would be really useful to allow the user's to scroll through previous console data.
Taking on board the suggestions in this thread I came up with the following:
Basically what I'm doing here is doing a quick 'scroll to end' to see if the current scroll position is at the end (by comparing the original to the 'end' position) and if it is, scrolling to the end (autoscroll = on). If it isn't, return back to the original scroll position. I found out that if you set the scroll position above the maximum value and then read the position - it will return the new actual position (rather than the large number you've just set it to).
I guess if you have a large amount of string data you might want to defer panel updates in case it flickers but this seemed to do the job for me!
Edit: I did actually end up doing a defer panel updates at the beginning/end of the VI as it was flickering to the bottom after I wrapped it into a SubVI.
03-17-2015 01:51 AM
Nice one Edjsch! Clean, simple, effective.