Thread Tools Display Modes
05-21-07, 12:39 AM   #1
GeoMancer
A Murloc Raider
Join Date: Jul 2006
Posts: 4
Scrolly-Polly

Alright, no code here, 'cause I haven't found anything that will work, or anything even close.

I have a large amount of text (Think 30+lines, which are can be 255 characters or longer), that I need to display within a mid-sized frame, say 300x450. The text is just in a simple variable, the lines divided by |n. The issue is that there is a chance that some of the lines of text when wrapped could be larger than the total display area. Of course a scrolling ability would be nice, but as if yet I can't figure out how to implement it.

It was suggested to me that I could make a a few FontStrings and do the scroll by changing their values, but I'm at a loss as to how to do that with the size strings that I'm dealing with, since most strings will end up being longer than the total available space in the little strings, and without dividing the the info into a table or something which I really don't want to do because that would require a -lot- of table entries for a lot of things.

So, er, any suggestions would be useful. And yes, this is a lua question, since I'm trying to write the frames and everything with the lua. ^^; Thanks in advance.
  Reply With Quote
05-21-07, 05:22 PM   #2
Riraito
An Aku'mai Servant
 
Riraito's Avatar
Join Date: Dec 2006
Posts: 32
here was some code I found in an AddOn a while ago, and used credit to anyone if they reconize it as there own, but it has worked nicely for me:

Code:
			<ScrollFrame name="NotePadTextScrollBar" inherits="UIPanelScrollFrameTemplate" virtual="true">
				<Size> <AbsDimension x="310" y="260"/> </Size>
				<Anchors> <Anchor point="BOTTOMLEFT"> <Offset> <AbsDimension x="9.5" y="77"/> </Offset> </Anchor> </Anchors>
				<Layers>			
					<Layer level="ARTWORK">
						<Texture name="$parentTop" file="Interface\PaperDollInfoFrame\UI-Character-ScrollBar">
							<Size> <AbsDimension x="30" y="50"/> </Size>
							<Anchors> <Anchor point="TOP" relativeTo="$parentScrollBarScrollUpButton"> 
								<Offset> <AbsDimension x="0" y="5"/> </Offset> </Anchor> </Anchors>
							<TexCoords left="1" right="1" top="1" bottom="1"/>
						</Texture>
						<Texture file="Interface\PaperDollInfoFrame\UI-Character-ScrollBar">
							<Size> <AbsDimension x="31" y="0"/> </Size>
							<Anchors> <Anchor point="BOTTOM" relativeTo="$parentScrollBarScrollDownButton">
								<Offset> <AbsDimension x="50" y="-2"/> </Offset> </Anchor> </Anchors>
							<TexCoords left="1" right="1" top="1" bottom="1"/>
						</Texture>
					</Layer>			
				</Layers>	
				<ScrollChild>
					<Frame enableMouse="true">
						<Size> <AbsDimension x="280" y="245"/> </Size>
						<Anchors> <Anchor point="TOPLEFT" relativeTo="NotePadMainFrame">
							<Offset> <AbsDimension x="25" y="-185"/> </Offset> </Anchor> </Anchors>
						<Frames>
							<EditBox name="NotesEdit" letters="7500" multiLine="true" enableMouse="true" autoFocus="false">
								<Size> <AbsDimension x="290" y="200"/> </Size>
								<Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="15" y="-5"/> </Offset> </Anchor> </Anchors>
								<FontString inherits="QuestFont"/>
								<Scripts>
									<OnShow>
										self:SetFocus()
									</OnShow>									
									<OnClick>
										self:SetFocus()
									</OnClick>
									<OnHide>
										self:ClearFocus()
									</OnHide>
									<OnEscapePressed>
										self:ClearFocus()
									</OnEscapePressed>
									<OnTextChanged>
										NotePad_NotesEdit_OnTextChanged(self)
									</OnTextChanged>
								</Scripts>
							</EditBox>
						</Frames>
					</Frame>
				</ScrollChild>
			</ScrollFrame>
and in the .lua

Code:
function NotePad_NotesEdit_OnTextChanged(self)
	local scrollBar = getglobal(self:GetParent():GetParent():GetName().."ScrollBar")
	self:GetParent():GetParent():UpdateScrollChildRect()
	local min, max = scrollBar:GetMinMaxValues()
	if ( max > 0 and (self.max ~= max) and 13 > max-NotePadTextScrollBar:GetVerticalScroll()) then
		self.max = max
		scrollBar:SetValue(max)
	end
	NotePadPVars.notes[NotePadVars.buttonSelected].text = NotesEdit:GetText() -- this is where I save the text
end
__________________
  Reply With Quote
05-23-07, 03:32 PM   #3
GeoMancer
A Murloc Raider
Join Date: Jul 2006
Posts: 4
I'm back again, with another question:
I want the scrollframe to scroll to the bottom whenever the text on it is updated. So, in the function that updates the text I have the following code (Not the actual code just a dumbed down version):

Code:
local scrollBar = getglobal(scrollFrame:GetName() .. "ScrollBar");
scrollBar:SetMaxValue(scrollFrame:GetVerticalScrollRange());
scrollBar:SetValue(scrollFrame:GetVerticalScrollRange());
scrollFrame:SetVerticalScroll(scrollFrame:GetVerticalScrollRange());
Which should work, since the GetVerticalScrollRange() And the max value of a ScrollBar should be the same from the two objects. The only thing is that it never actually scrolls it to the bottom. It scrolls it to the size of the prior change, rather than the current change (11 pixels off per line of text added) which defeats the attempt to simulate a scrolling-chat frame.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Scrolly-Polly


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