Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2007
    Posts
    172

    Star Tree go previous node and go next node ?

    there is a problem with my code but i couldnt find it !!! i have 2 buttons "previous" and "next" for tree object;

    previous button code :
    Code:
    nCount = Tree.GetChildCount("Tree1", "0");
    if (nCount > 0) then
    Tree.SetSelectedNode("Tree1", tostring(nInd));
        MediaPlayer.Load("media1", Tree.GetNode("Tree1", nInd).Data);
        if (nInd == nCount) then
            nInd = 1;
        else
    		nInd = nInd - 1;
        end
    end
    next button code :
    Code:
    nCount = Tree.GetChildCount("Tree1", "0");
    if (nCount > 0) then
    Tree.SetSelectedNode("Tree1", tostring(nInd));
        MediaPlayer.Load("media1", Tree.GetNode("Tree1", nInd).Data);
        if (nInd == nCount) then
            nInd = 1;
        else
    		nInd = nInd + 1;
        end
    end
    when i click next button it works ok and jumps the next node but once if i click the previous button it jumps to first node not the one before selected and then next button gives the same error !!!
    Attached Images

  2. #2
    Join Date
    Sep 2008
    Posts
    14

    Post

    * On Click the button "Previous":
    Code:
    local strSelectedNode = Tree.GetSelectedNode("Tree1");
    if (strSelectedNode ~= "") then
        if (strSelectedNode == "1") then
            nInd = Tree.GetChildCount("Tree1", "0");
        else
            nInd = tonumber(strSelectedNode) - 1;
        end
        Tree.SetSelectedNode("Tree1", tostring(nInd));
        --MediaPlayer.Load("media1", Tree.GetNode("Tree1", tostring(nInd)).Data);
    else
        Tree.SetSelectedNode("Tree1", "1");
    end
    * On Click the button "Next":
    Code:
    local strSelectedNode = Tree.GetSelectedNode("Tree1");
    if (strSelectedNode ~= "") then
        if (tonumber(strSelectedNode) == Tree.GetChildCount("Tree1", "0")) then
            nInd = 1;
        else
            nInd = tonumber(strSelectedNode) + 1;
        end
        Tree.SetSelectedNode("Tree1", tostring(nInd));
        --MediaPlayer.Load("media1", Tree.GetNode("Tree1", tostring(nInd)).Data);
    else
        Tree.SetSelectedNode("Tree1", "1");
    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts