Reply
Thread Tools Display Modes
Unread 02-26-13, 10:55 AM   #1
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 243
ChatFrame#:ScrollToTop() Alternative

Something that has been irritating me lately is Blizzard's ChatFrame#:ScrollTopTop() function. It situates the highest scroll index of text against the bottom of the chat frame. This isn't even achievable through normal scrolling up, as the chat stops scrolling when the highest index is situated at the top of the chat frame. I wrote this script to try to get around that.

Lua Code:
  1. for i = 0, _G[frame]:GetMaxLines() do
  2.     if _G[frame]:AtTop() then break end
  3.     _G[frame]:ScrollUp()
  4. end

This really satiates some sort of pseudo obsessive-compulsiveness, and doesn't really enhance anything drastically. I searched high and low for something similar and didn't find anything.

The script should fit in neatly wherever there is a call to ChatFrame#:ScrollToTop().
Clamsoda is offline   Reply With Quote
Unread 02-26-13, 04:49 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,282
You could simplify that:

Code:
repeat
    ChatFrame1:ScrollUp()
until ChatFrame1:AtTop()
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 02-26-13, 05:40 PM   #3
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 243
=O Suppp Phanxxxxxxxxxx.

Looks great! Thank you for the input. I was unaware that LUA had a repeat-until function.

Last edited by Clamsoda : 02-26-13 at 05:54 PM.
Clamsoda is offline   Reply With Quote
Unread 02-26-13, 06:46 PM   #4
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 552
You could also just do
Lua Code:
  1. while not ChatFrame1:AtTop() do
  2.   ChatFrame1:ScrollUp()
  3. end

The difference is a repeat loop will always execute at least once.

Last edited by semlar : 02-26-13 at 06:48 PM.
semlar is online now   Reply With Quote
Unread 02-27-13, 04:52 PM   #5
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 243
Works great, Semlar.

Thanks a lot for the input you two, I didn't even think to use a repeat-until or while-end function in this situation.
Clamsoda is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Tutorials & Other Helpful Info. » ChatFrame#:ScrollToTop() Alternative

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off