Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 1, 2010, 2:04:54 PM (14 years ago)
Author:
konrad
Message:

—function to iterate throgh a menusheet by using arrowkeys is added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menu/data/gui/scripts/GUITools.lua

    r7663 r7687  
    5555end
    5656
     57--function to iterate through a menu sheet by using arrowkeys
    5758
    5859--@arguments:
    5960--  list: 2-dimensional table, arguments are items that contain a button and its function
     61--        !!note: each button can only be in the list once!!
    6062--  code: code of any key on the keyboard
    6163--  P: menusheet
    62 --  n: number of rows
    63 --  m: number of colums
     64--  n: number of rows of the buttontable
     65--  m: number of colums of the buttontable
    6466
    6567function buttonIteratorHelper(list, code, P, n, m)
     68
     69    --after a key (down,up,left,right) is pressed the index of the current button has to be updated   
    6670
    6771    --key down
     
    7276        else
    7377            P.oldindex = P.index
    74             P.index = (P.index + m) % (m*n)
    75 
    76             while list[P.index+1] == nil do
     78            P.index = (P.index + m) % (m*n)     --modulo operation works as a "wrap around" in the button menu
     79                                               
     80            while list[P.index+1] == nil do     
    7781                P.oldindex = P.index
    7882                P.index = (P.index + m) % (m*n)
     
    98102
    99103            while list[P.index+1] == nil do
    100                 cout(0,P.index)
    101104                P.oldindex = P.index
    102105                P.index = (P.index-m)%(m*n)
     
    162165    end
    163166       
     167    --to update the new current button
    164168    if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then
    165169
     
    171175
    172176        --teste ob der Button nicht schon gehighlightet ist
    173         cout(0,child:getProperty("NormalImageRightEdge"))
    174177        if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then
    175178            --nop
     
    189192        end
    190193
     194        --for every highlighted button check if index is on its position. If not, set imageproperty on "normal"
    191195        local i = 1
    192196        while i < (n*m) do
     
    220224    end
    221225
    222     cout(0, P.oldindex)
    223     cout(0, P.index)
    224 
    225 end
    226 
     226end
     227
     228--write index and oldindex on the console
     229--works like buttonIteratorHelper
    227230function indexTester(list,code,P,n,m)
    228231    --key down
Note: See TracChangeset for help on using the changeset viewer.