Quantcast WoWInterface - View Single Post - Changes to ScrollingMessageFrame?
View Single Post
05-15-16, 09:04 AM   #2
Jarod24
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 66
Relevant LUA

Code:
function IfThen:Frame_Search(searchBox, outputBox, searchMode)
	cache_helpPageType = "argument";
	local text = strlower(strtrim(searchBox:GetText()));
	--pprint("Frame_Search", text);
	if (text == strlower(searchBox:GetAttribute("defaultString"))) then text = ""; end	--Ignore the default 'Search' text in the box
	if (text == cache_previousSearchBoxString) then return nil; end	--Don't do anything if the searchstring matches that of the previous call (This happens when switching pages and when user first clicks in the searchbox and 'Search' is cleared from it).
	cache_previousSearchBoxString = text;

		local scrollText = self:getScrollText(cache_helpPageType);

		outputBox:Clear();
		if (scrollText == nil) then  return nil; end

		--Help page. Populate the scrollframe with the result...
		local strlen = strlen; --local fpointer
		local strsub = strsub;
		local strCol = cache_Color_Function; --Blue for most things
		if (cache_helpPageType == "variable") then strCol = cache_Color_Variable; end --Variable color
		if (scrollText ~= nil) then
			pprint("len",#scrollText);
			for i=#scrollText, 1, -1 do --iterate in reverse so that the listing is the same as in the text
				local strKey	= scrollText[i];
				local strTitle	= scrollText[i];
				if (strlen(strTitle) > 19) then strTitle = strsub(strTitle, 1, 16) .."..."; end --if the string is bigger than 18 chars then put a ... at the end
				outputBox:AddMessage(strCol.."|Hplayer:"..strKey.."|h>"..strTitle.."|h|r");			  --max 19 characters in length -- XXOOXXOOXXOOXXOOXXO
			end--for
		end--if
	return nil;
end


XML
Code:
<Frame name="IfThenXML_Help_Frame" parent="UIParent" movable="false" resizable="false" enableKeyboard="true" enableMouseWheel="true" enableMouse="true" frameStrata="HIGH" toplevel="true" hidden="true">
	<!-- Size is adjusted by setting anchors relative to parent -->
	<Anchors>
		<Anchor point="TOPLEFT"><Offset><RelDimension x="0.07" y="-0.02315"/></Offset></Anchor>
		<Anchor point="BOTTOMRIGHT"><Offset><RelDimension x="-0.07" y="0.07"/></Offset></Anchor>
	</Anchors>
	<!-- Titleregion is the area where the user can click and move the frame -->
	<TitleRegion>
		<Anchors>
			<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
			<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="TOPRIGHT"><Offset><AbsDimension x="0" y="-25"/></Offset></Anchor>
		</Anchors>
	</TitleRegion>
	<Scripts>
		<OnKeyDown>if (key=="ESCAPE") then IfThen:Help_Close(); end</OnKeyDown>
		<OnMouseDown>IfThen:ToggleFrameStrata(self, true);</OnMouseDown>
		<OnUpdate>IfThen:ToggleFrameStrata(self, false);</OnUpdate>
	</Scripts>

	<Backdrop bgFile="Interface\TutorialFrame\TutorialFrameBackground" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
		<EdgeSize><AbsValue val="16"/></EdgeSize>
		<TileSize><AbsValue val="32"/></TileSize>
		<BackgroundInsets><AbsInset left="5" right="5" top="5" bottom="5"/></BackgroundInsets>
	</Backdrop>

	<!-- The info-text and form title -->
	<Layers>
		<Layer level="ARTWORK">
			<!-- At the top of the form -->
			<FontString name="IfThenXML_Help_Title" inherits="IfThenXML_Font_Title" text="IfThen: More help">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"><Offset><AbsDimension x="10" y="-15"/></Offset></Anchor>
				</Anchors>
			</FontString>
		</Layer>

		<Layer level="BACKGROUND">
			<Texture>
				<Color r="0" g="0" b="0" a="0.70"/>
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
					<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
				</Anchors>
			</Texture>
		</Layer>
	</Layers>

	<Frames>
		<!-- At the top of the form -->
		<Button name="IfThenXML_Help_CloseButton1" inherits="UIPanelCloseButton">
			<Anchors>
				<Anchor point="TOPRIGHT"><Offset><AbsDimension x="-3" y="-3" /></Offset></Anchor>
			</Anchors>
			<Scripts>
				<OnClick>IfThen:Help_Close();</OnClick>
			</Scripts>
		</Button>


		<!-- Search box -->
		<EditBox name="IfThenXML_Help_SearchBox" inherits="IfThen_FilterBoxTemplate" autoFocus="true">
			<Anchors>
				<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"><Offset><AbsDimension x="14" y="-40"/></Offset></Anchor>
				<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="TOPLEFT"><Offset><AbsDimension x="200" y="-61"/></Offset></Anchor>
			</Anchors>
			<Scripts>
				<OnTextChanged>IfThen:Frame_Search(self, IfThenXML_Help_ScrollFrameList);</OnTextChanged>
				<!-- SearchBox is hidden and shown again between page switches. This makes sure that the search is redone with on the proper list of arguments -->
				<OnShow>IfThen:Frame_Search(self, IfThenXML_Help_ScrollFrameList);</OnShow>
				<OnEscapePressed>if (tostring(self:GetText())=="") then IfThen:Help_Close(); else IfThen:Frame_SearchClear(self, IfThenXML_Help_SearchBoxClearButton); end</OnEscapePressed>
			</Scripts>
		</EditBox>

		<!-- Inner frame around the ScrollFrame and ScrollingMessageFrame -->
		<Frame name="IfThenXML_Help_SubFrameScroll">
			<Anchors>
				<Anchor point="TOPLEFT" relativeTo="IfThenXML_Help_SearchBox" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="-7" y="0"/></Offset></Anchor>
				<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="200" y="33"/></Offset></Anchor>
			</Anchors>

			<!-- This defines the outer frame texture for the scrollframe -->
			<Backdrop bgFile="Interface\ChatFrame\ChatFrameBackground" edgeFile="Interface\Buttons\UI-SliderBar-Border" tile="true">
				<BackgroundInsets><AbsInset left="3" right="3" top="6" bottom="6" /></BackgroundInsets>
				<TileSize><AbsValue val="16" /></TileSize>
				<EdgeSize><AbsValue val="9" /></EdgeSize>
			</Backdrop>

			<Frames>
				<ScrollFrame name="IfThenXML_Help_ScrollFrameScroll" inherits="UIPanelScrollFrameTemplate">
					<Anchors>
						<Anchor point="TOPLEFT" relativeTo="IfThenXML_Help_SubFrameScroll" relativePoint="TOPLEFT"><Offset><AbsDimension x="6" y="-12"/></Offset></Anchor>
						<Anchor point="BOTTOMRIGHT" relativeTo="IfThenXML_Help_SubFrameScroll" relativePoint="BOTTOMRIGHT"><Offset><AbsDimension x="-26" y="8"/></Offset></Anchor>
					</Anchors>

					<Layers>
						<!-- Background for the Slider -->
						<Layer level="BORDER">
							<Texture file="Interface\ChatFrame\ChatFrameBackground">
								<Gradient>
									<MinColor r="0.1" g="0.1" b="0.1"/>
									<MaxColor r="0" g="0" b="0"/>
								</Gradient>
								<Anchors>
									<Anchor point="TOPLEFT" relativeTo="IfThenXML_Help_ScrollFrameScroll" relativePoint="TOPRIGHT"><Offset><AbsDimension x="0" y="6"/></Offset></Anchor>
									<Anchor point="BOTTOMRIGHT" relativeTo="IfThenXML_Help_ScrollFrameScroll" relativePoint="BOTTOMRIGHT"><Offset><AbsDimension x="23" y="-2"/></Offset></Anchor>
								</Anchors>
							</Texture>
						</Layer>

						<!-- Background for the ScrollingMessageFrame -->
						<Layer level="BACKGROUND">
							<Texture name="IfThenXML_Help_SubFrameScroll_Simple_Background">
								<Color r="0" g="0" b="0" a="1"/>
								<Anchors>
									<Anchor point="TOPLEFT" relativeTo="IfThenXML_Help_ScrollFrameScroll" relativePoint="TOPLEFT"><Offset><AbsDimension x="-4" y="5"/></Offset></Anchor>
									<Anchor point="BOTTOMRIGHT" relativeTo="IfThenXML_Help_ScrollFrameScroll" relativePoint="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="-2"/></Offset></Anchor>
								</Anchors>
							</Texture>
						</Layer>
					</Layers>

					<ScrollChild>
						<!-- Scrollframe for function names -->
						<ScrollingMessageFrame name="IfThenXML_Help_ScrollFrameList" movable="true" m_axLines="1000" n_umLinesDisplayed="1000" i_ndentedWordWrap="false" d_isplayDuration="0" f_ading="false" insertmode="TOP">
							<!-- Because of how Scrollframe works we need to set a .Width and .Height -->
							<!-- This is dynamically adjusted in the <OnSizeChanged> event of the ScrollFrame -->
							<Size><AbsDimension x="100" y="100"/></Size>
							<Scripts>
								<OnHyperlinkClick>IfThen:Help_OnHyperlinkShow(self, link, text, button);</OnHyperlinkClick>
							</Scripts>

							<FontString inherits="IfThenXML_Font_Help_ScrollList" justifyH="LEFT" indentedWordWrap="false" nonspacewrap="true"/>
						</ScrollingMessageFrame>
					</ScrollChild>
				</ScrollFrame>
			</Frames>
		</Frame>

		<!-- Inner frame around the ScrollFrame and EditBox -->
		<Frame name="IfThenXML_Help_SubFrame">
			<Anchors>
				<Anchor point="TOPLEFT" relativeTo="IfThenXML_Help_SearchBox" relativePoint="TOPRIGHT"><Offset><AbsDimension x="2" y="3"/></Offset></Anchor>
				<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT"><Offset><AbsDimension x="-5" y="33"/></Offset></Anchor>
			</Anchors>

			<!-- This defines the outer frame texture for the scrollframe -->
			<Backdrop bgFile="Interface\ChatFrame\ChatFrameBackground" edgeFile="Interface\Buttons\UI-SliderBar-Border" tile="true">
				<BackgroundInsets><AbsInset left="3" right="3" top="6" bottom="6" /></BackgroundInsets>
				<TileSize><AbsValue val="16" /></TileSize>
				<EdgeSize><AbsValue val="9" /></EdgeSize>
			</Backdrop>

			<Frames>
				<ScrollFrame name="IfThenXML_Help_ScrollFrame" inherits="UIPanelScrollFrameTemplate">
					<Anchors>
						<Anchor point="TOPLEFT"><Offset><AbsDimension x="6" y="-12"/></Offset></Anchor>
						<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-26" y="8"/></Offset></Anchor>
					</Anchors>

					<Layers>
						<!-- Background for the Slider -->
						<Layer level="BORDER">
							<Texture file="Interface\ChatFrame\ChatFrameBackground">
								<Gradient>
									<MinColor r="0.1" g="0.1" b="0.1"/>
									<MaxColor r="0" g="0" b="0"/>
								</Gradient>
								<Anchors>
									<Anchor point="TOPLEFT" relativeTo="IfThenXML_Help_ScrollFrame" relativePoint="TOPRIGHT"><Offset><AbsDimension x="0" y="6"/></Offset></Anchor>
									<Anchor point="BOTTOMRIGHT" relativeTo="IfThenXML_Help_ScrollFrame" relativePoint="BOTTOMRIGHT"><Offset><AbsDimension x="23" y="-2"/></Offset></Anchor>
								</Anchors>
							</Texture>
						</Layer>

						<!-- Background for the Editbox -->
						<Layer level="BACKGROUND">
							<Texture name="IfThenXML_Help_SubFrame_Simple_Background">
								<Color r="0" g="0" b="0" a="1"/>
								<Anchors>
									<Anchor point="TOPLEFT" relativeTo="IfThenXML_Help_ScrollFrame" relativePoint="TOPLEFT"><Offset><AbsDimension x="-5" y="6"/></Offset></Anchor>
									<Anchor point="BOTTOMRIGHT" relativeTo="IfThenXML_Help_ScrollFrame" relativePoint="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="-2"/></Offset></Anchor>
								</Anchors>
							</Texture>
						</Layer>
					</Layers>

					<ScrollChild>
						<EditBox name="IfThenXML_Help_EditBox" multiLine="true" maxLines="1000" letters="0" nonspacewrap="true" spacing="1" autoFocus="false">
							<!-- Because of how Scrollframe works we need to set a .Width and .Height -->
							<!-- This is dynamically adjusted in the <OnSizeChanged> event of the ScrollFrame -->
							<Size><AbsDimension x="100" y="100"/></Size>
							<Scripts>
								<OnLoad>self:SetHyperlinksEnabled(true);</OnLoad>
								<OnEscapePressed>IfThen:Help_Close();</OnEscapePressed>
								<!-- OnUpdate and OnCursorChanged here is what makes the scrolling respond to the arrowkeys -->
								<OnUpdate>ScrollingEdit_OnUpdate(self, elapsed, self:GetParent());</OnUpdate>
								<OnCursorChanged function="ScrollingEdit_OnCursorChanged"/>
								<!-- This lets us toggle topmost focus of the frame -->
								<OnMouseDown>IfThen:ToggleFrameStrata(IfThenXML_Help_Frame, true);</OnMouseDown>
								<OnHyperlinkClick>IfThen:HyperLink_EventHandler(link, text, button);</OnHyperlinkClick>
							</Scripts>
							<FontString inherits="IfThenXML_Font_Help"/>
						</EditBox>
					</ScrollChild>

					<Scripts>
						<OnSizeChanged>
							local edt = IfThenXML_Help_EditBox;
							edt:SetWidth(self:GetWidth());
							edt:SetHeight(self:GetHeight());
						</OnSizeChanged>
					</Scripts>
				</ScrollFrame>
			</Frames>
		</Frame>

	</Frames>
</Frame>
__________________
Author of IfThen, Links in Chat