Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Oct 18, 2017 12:43 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: LineNumAtCharPos and ScrollPosition
PostPosted: Sun Mar 24, 2013 9:07 pm 
Offline

Joined: Fri Jul 21, 2006 12:28 am
Posts: 509
I have an application that reads a log file into a text area when it opens. I want to set the scroll position to the end of the text so that the most recent log entries are visible when the window opens. The following code in the window open event works in OS X but not in Windows:
TextArea.ScrollPosition = TextArea.LineNumAtCharPos(TextArea.Text.Len)

If I put the code in the window activate event the scroll position is correct in Windows but the text area is blank until the scrollbar is moved by the user as the text doesn't draw until then even though it's read in in the Window open event.

What needs to be done in Windows to get this to work properly?

_________________
Regards,
Carl
Capaho Web
http://www.capaho.com


Top
 Profile  
Reply with quote  
 Post subject: Re: LineNumAtCharPos and ScrollPosition
PostPosted: Sun Mar 24, 2013 10:22 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
I ran in to so many issues with the built-in TextAreas that I just switched to using an HTMLViewer.. I know not a real answer, but it is an alternative if you are so inclined..

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: LineNumAtCharPos and ScrollPosition
PostPosted: Sun Mar 24, 2013 11:00 pm 
Offline

Joined: Fri Jul 21, 2006 12:28 am
Posts: 509
shaosean wrote:
I ran in to so many issues with the built-in TextAreas that I just switched to using an HTMLViewer.. I know not a real answer, but it is an alternative if you are so inclined..

Thanks for the tip. The TextArea is read only, so replacing it with an HTMLViewer might be an acceptable workaround if I can't find a solution for the TextArea.ScrollPosition problem in Windows.

_________________
Regards,
Carl
Capaho Web
http://www.capaho.com


Top
 Profile  
Reply with quote  
 Post subject: Re: LineNumAtCharPos and ScrollPosition
PostPosted: Tue Mar 26, 2013 6:10 am 
Offline

Joined: Wed Dec 14, 2011 4:20 am
Posts: 84
capaho wrote:
I have an application that reads a log file into a text area when it opens. I want to set the scroll position to the end of the text so that the most recent log entries are visible when the window opens. The following code in the window open event works in OS X but not in Windows:
TextArea.ScrollPosition = TextArea.LineNumAtCharPos(TextArea.Text.Len)

If I put the code in the window activate event the scroll position is correct in Windows but the text area is blank until the scrollbar is moved by the user as the text doesn't draw until then even though it's read in in the Window open event.

What needs to be done in Windows to get this to work properly?



If I'm not mistaken, looks like you are using: TextArea1.text = Your_Logfile

If this is the case, try following: TextArea1.Appentext YourLogfile

When you use TextArea1.Appentext the scroll position will be in the bottom and you don't need to use your code above


Top
 Profile  
Reply with quote  
 Post subject: Re: LineNumAtCharPos and ScrollPosition
PostPosted: Tue Mar 26, 2013 2:18 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
http://docs.realsoftware.com/index.php/ ... AppendText

Using the AppendText method is also a lot faster than adding two strings together..

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: LineNumAtCharPos and ScrollPosition
PostPosted: Tue Mar 26, 2013 8:31 pm 
Offline

Joined: Fri Jul 21, 2006 12:28 am
Posts: 509
J.Hansen wrote:
If I'm not mistaken, looks like you are using: TextArea1.text = Your_Logfile

If this is the case, try following: TextArea1.Appentext YourLogfile

When you use TextArea1.Appentext the scroll position will be in the bottom and you don't need to use your code above

Thanks for the info. The log file is read into a string variable using TextInputStream, then TextArea.Text is given the value of the string variable. Using TextArea.AppendText moves the scrollbar in Windows, so that solves the problem there, but it doesn't move the scrollbar in OS X. This code gets the desired result on both platforms:
TextArea.AppendText s
TextArea.ScrollPosition = TextArea.LineNumAtCharPos(s.Len)

_________________
Regards,
Carl
Capaho Web
http://www.capaho.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group