Thread Tools Display Modes
12-29-08, 01:19 PM   #1
Felankor
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2007
Posts: 26
Question FauxScrollFrame_OnVerticalScroll Problem

Hi,

I added FauxScrollFrame's to my addon back in interface 20400 (Which at the time worked fine). I then quit WoW for a while and now Im comming back...

All of a sudden im getting an error when i try to scroll the frames vertically. I haven't changed nothing in my code... and i can't figure out what the problem is.

The error message is:
Interface\FrameXML\UIPanelTemplates.lua:230: attempt to index local 'self' (a number value)
NOTE: Im using the trial client until 2morro. Don't know if that affects anything. Don't see why it should but you never know...

I tried to install the FrameXML interface code from blizzard but it just creates an empty folder (Im guessing its something to do with me using the trial client) so I couldn't look for line 230 in UIPanelTemplates.lua.

Here's my code:

XML:
Code:
<!-- Start of FFSlashScrollBar ScrollFrame -->
            <ScrollFrame name="FFSlashScrollBar" inherits="FauxScrollFrameTemplate" hidden="false">
                <Size>
                    <AbsDimension x="163" y="138" />
                </Size>
                <Anchors>
                    <Anchor point="TOPLEFT">
                        <Offset>
                            <AbsDimension x="23" y="-64" />
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnVerticalScroll>
                        FauxScrollFrame_OnVerticalScroll(16, FFSlashScrollBar_Update);
                    </OnVerticalScroll>
                    <OnShow>
                        FFSlashScrollBar_Update();
                    </OnShow>
                </Scripts>
            </ScrollFrame>
<!-- End of FFSlashScrollBar ScrollFrame -->
LUA:
Code:
function FFSlashScrollBar_Update()
  local SlashLine = nil; -- 1 through 8 of our window to scroll
  local SlashLinePlusOffset = nil; -- an index into our data calculated from the scroll offset
  local FFSlashHighlighted = false;
    
    FauxScrollFrame_Update(FFSlashScrollBar,table.getn(FFSLASH_HELP_LIST_COMMANDS_TABLE),8,16);
    
    for SlashLine=1,8 do
        SlashLinePlusOffset = SlashLine + FauxScrollFrame_GetOffset(FFSlashScrollBar);
        
        if SlashLinePlusOffset <= table.getn(FFSLASH_HELP_LIST_COMMANDS_TABLE) then
            getglobal("FFSlashEntry"..SlashLine.."ButtonTextName"):SetText(FF_ColourText(FFSLASH_HELP_LIST_COMMANDS_TABLE[SlashLinePlusOffset], "blue", 0, 0));
            
            if (FFSlashHelpSelected == SlashLinePlusOffset) then
                --Show selection highlight
                FFHelp_ShowHighlight("FFSlashEntry"..SlashLine);
                FFSlashHighlighted = true;
            elseif (FFSlashHighlighted == false) then
                --Hide selection highlight
                FFHelp_HideSlashHighlight();
            end
            
            getglobal("FFSlashEntry"..SlashLine):Show();
        else
            getglobal("FFSlashEntry"..SlashLine):Hide();
        end
        
    end
  
end
Thanks in advance

Felankor
  Reply With Quote
12-29-08, 01:32 PM   #2
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
I recommend this site: www.wowcompares.com

It has all the Blizzard files for Beta, Test, and Public releases.

Here is the UIPanelTemplates.lua for the current Public patch (3.0.3): http://wowcompares.com/3039183/Frame...lTemplates.lua

So, it seems you need this function (right around line 230):
Code:
function FauxScrollFrame_OnVerticalScroll(self, value, itemHeight, updateFunction)
	local scrollbar = getglobal(self:GetName().."ScrollBar");
	scrollbar:SetValue(value);
	self.offset = floor((value / itemHeight) + 0.5);
	updateFunction(self);
end
I hope this helps!
__________________
Never be satisfied with satisfactory.
  Reply With Quote
12-29-08, 01:52 PM   #3
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
You need to pass "self" as the first argument of FauxScrollFrame_OnVerticalScroll.

So in your XML (never used XML so this is a guess) you replace:

xml Code:
  1. <OnVerticalScroll>
  2.    FauxScrollFrame_OnVerticalScroll(16, FFSlashScrollBar_Update);
  3. </OnVerticalScroll>

with
xml Code:
  1. <OnVerticalScroll>
  2.    FauxScrollFrame_OnVerticalScroll(self, 16, FFSlashScrollBar_Update);
  3. </OnVerticalScroll>

Last edited by Slakah : 12-29-08 at 01:55 PM.
  Reply With Quote
12-30-08, 03:00 AM   #4
Felankor
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2007
Posts: 26
Thank you both for your reply.

Cralor thank you for the URL. That will help me solve my own problems next time However I don't need to include that function in my own code as it is part of blizzards UI and can be used by any custom addons. The function you posted was enough for me to spot the problem though, which is what Slakah pointed out.

Slakah you are correct, Blizzard must have changed the function since patch 2.4 because I never had to pass that argument in the past... Im not sure if passing self is correct though. I can't remember if self actually passes the reference of the object. I may have to pass the text based name of the XML object, or a reference using getglobal.

I'll use the site Cralor suggested to look at an existing scroll frame in blizzards UI to see what they pass to the function.

Thank you both.

Felankor
  Reply With Quote
12-30-08, 08:51 AM   #5
twobits
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 38
Originally Posted by Felankor View Post

Slakah you are correct, Blizzard must have changed the function since patch 2.4 because I never had to pass that argument in the past... Im not sure if passing self is correct though. I can't remember if self actually passes the reference of the object. I may have to pass the text based name of the XML object, or a reference using getglobal.

I'll use the site Cralor suggested to look at an existing scroll frame in blizzards UI to see what they pass to the function.

Thank you both.

Felankor
Right, it changed in 3.0... and it is not self, xml templates automatically add the self in for you... it is the the offset you need to add or rather what the function is calling 'value'.
  Reply With Quote
01-02-09, 01:57 PM   #6
Felankor
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2007
Posts: 26
Thank you all for your help. I had a look at blizzards code for the friend list and now have it working. I changed:
Code:
FauxScrollFrame_OnVerticalScroll(16, FFSlashScrollBar_Update);

to

FauxScrollFrame_OnVerticalScroll(self, offset, 16, FFSlashScrollBar_Update);
and it worked.

Thanks Felankor
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » FauxScrollFrame_OnVerticalScroll Problem

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