WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   FauxScrollFrame_OnVerticalScroll Problem (https://www.wowinterface.com/forums/showthread.php?t=19921)

Felankor 12-29-08 01:19 PM

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:
Quote:

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

Cralor 12-29-08 01:32 PM

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!

Slakah 12-29-08 01:52 PM

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>

Felankor 12-30-08 03:00 AM

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

twobits 12-30-08 08:51 AM

Quote:

Originally Posted by Felankor (Post 113609)

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'.

Felankor 01-02-09 01:57 PM

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


All times are GMT -6. The time now is 10:17 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI