Index: /code/branches/menu/data/gui/scripts/CreditsMenu.lua
===================================================================
--- /code/branches/menu/data/gui/scripts/CreditsMenu.lua	(revision 7662)
+++ /code/branches/menu/data/gui/scripts/CreditsMenu.lua	(revision 7663)
@@ -2,4 +2,19 @@
 
 local P = createMenuSheet("CreditsMenu")
+
+P.buttonList = {}
+
+function P.onLoad()
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/CreditsBackButton"),
+            ["function"]  = P.CreditsBackButton_clicked
+    }
+    P.buttonList[1] = item
+end
+
+function P.onShow()
+    P.oldindex = -2
+    P.index = -1
+end
 
 function P.CreditsBackButton_clicked(e)
@@ -7,4 +22,8 @@
 end
 
+function P.onKeyPressed() 
+    buttonIteratorHelper(P.buttonList, code, P, 1, 1)
+end
+
 return P
 
Index: /code/branches/menu/data/gui/scripts/GUITools.lua
===================================================================
--- /code/branches/menu/data/gui/scripts/GUITools.lua	(revision 7662)
+++ /code/branches/menu/data/gui/scripts/GUITools.lua	(revision 7663)
@@ -54,2 +54,278 @@
     return height
 end
+
+
+--@arguments:
+--  list: 2-dimensional table, arguments are items that contain a button and its function
+--  code: code of any key on the keyboard
+--  P: menusheet
+--  n: number of rows
+--  m: number of colums
+
+function buttonIteratorHelper(list, code, P, n, m)
+
+    --key down
+    if code == "208" then
+        if P.index < 0 then     -- initial status
+            P.index = 0
+            P.oldindex = -1
+        else
+            P.oldindex = P.index
+            P.index = (P.index + m) % (m*n)
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = (P.index + m) % (m*n)
+            end
+        end
+
+    --key up
+    elseif code == "200" then
+        if P.index < 0 then
+            P.index = 0
+            P.oldindex = -1
+        elseif(P.index == 0) then
+            P.oldindex = P.index
+            P.index = m*n-m
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = (P.index-m)%(m*n)
+            end
+        else
+            P.oldindex = P.index
+            P.index = (P.index -m) % (m*n)
+
+            while list[P.index+1] == nil do
+                cout(0,P.index)
+                P.oldindex = P.index
+                P.index = (P.index-m)%(m*n)
+            end
+        end
+
+    --key right
+    elseif code == "205" then
+        if P.index < 0 then
+            P.index = 0
+            P.oldindex = -1
+        elseif (P.index+1) % m == 0 then     -- we are at the right-end of a row
+            P.oldindex = P.index
+            P.index = P.index + 1 -m
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = P.index + 1
+            end
+        else
+            P.oldindex = P.index
+            P.index = P.index + 1
+
+            while list[P.index+1] == nil do
+                if (P.index+1) % m == 0 then     -- we are at the right-end of a row
+                    P.oldindex = P.index
+                    P.index = P.index + 1-m
+
+                else    
+                    P.oldindex = P.index
+                    P.index = P.index + 1
+                end
+            end
+        end    
+
+    --key left
+    elseif code == "203" then
+        if P.index < 0 then
+            P.index = 0
+            P.oldindex = -1
+        elseif P.index % m == 0 then         -- we are at the left-end of a row 
+            P.oldindex = P.index
+            P.index = P.index +m-1
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = P.index -1
+            end
+        else
+            P.oldindex = P.index
+            P.index = P.index -1
+
+            while list[P.index+1] == nil do
+                if P.index % m == 0 then     -- we are at the left-end of a row 
+                    P.oldindex = P.index
+                    P.index = P.index -1 + m
+                else                
+                    P.oldindex = P.index
+                    P.index = P.index -1
+                end
+            end   
+        end
+    end
+       
+    if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then
+
+        local system = CEGUI.System:getSingleton()
+        local window = winMgr:getWindow("orxonox/MainMenuBackground")
+
+        local item = list[P.index+1]
+        local child = item["button"] 
+
+        --teste ob der Button nicht schon gehighlightet ist
+        cout(0,child:getProperty("NormalImageRightEdge"))
+        if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then
+            --nop
+        else
+            child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")
+            child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")
+            child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")
+            if P.oldindex >= 0 then
+                if list[P.oldindex+1] ~= nil then
+                    local item = list[P.oldindex+1]
+                    local oldChild = item["button"]
+                    oldChild:setProperty("NormalImageRightEdge", string.sub(oldChild:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
+                    oldChild:setProperty("NormalImageLeftEdge", string.sub(oldChild:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
+                    oldChild:setProperty("NormalImageBackground", string.sub(oldChild:getProperty("NormalImageBackground"),1,-10) .. "Normal")
+                end
+            end
+        end
+
+        local i = 1
+        while i < (n*m) do
+            if i == P.index +1 then 
+                i = i+1
+            else
+                if list[i] ~= nil then 
+                local item = list[i]
+                local child = item["button"]
+                    if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then
+                        child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
+                        child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
+                        child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
+                    end
+                end
+            end
+                i=i+1
+        end
+    end
+    
+    --enter
+    if code == "28" then
+        local item = list[P.index+1]
+        local child = item["button"] 
+        child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
+        child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
+        child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
+
+        local foo = item["function"]
+        foo()
+    end
+
+    cout(0, P.oldindex)
+    cout(0, P.index)
+
+end
+
+function indexTester(list,code,P,n,m)
+    --key down
+    if code == "208" then
+        if P.index < 0 then     -- initial status
+            P.index = 0
+            P.oldindex = -1
+        else
+            P.oldindex = P.index
+            P.index = (P.index + m) % (m*n)
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = (P.index + m) % (m*n)
+            end
+        end
+
+    --key up
+    elseif code == "200" then
+        if P.index < 0 then
+            P.index = 0
+            P.oldindex = -1
+        elseif(P.index == 0) then
+            P.oldindex = P.index
+            P.index = m*n-m
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = (P.index-m)%(m*n)
+            end
+        else
+            P.oldindex = P.index
+            P.index = (P.index -m) % (m*n)
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = P.index -m
+            end
+        end
+
+    --key right
+    elseif code == "205" then
+        if P.index < 0 then
+            P.index = 0
+            P.oldindex = -1
+        elseif (P.index+1) % m == 0 then     -- we are at the right-end of a row
+            P.oldindex = P.index
+            P.index = P.index + 1 -m
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = P.index + 1
+            end
+        else
+            P.oldindex = P.index
+            P.index = P.index + 1
+
+            while list[P.index+1] == nil do
+                if (P.index+1) % m == 0 then     -- we are at the right-end of a row
+                    P.oldindex = P.index
+                    P.index = P.index + 1-m
+
+                else    
+                    P.oldindex = P.index
+                    P.index = P.index + 1
+                end
+            end
+        end    
+
+    --key left
+    elseif code == "203" then
+        if P.index < 0 then
+            P.index = 0
+            P.oldindex = -1
+        elseif P.index % m == 0 then         -- we are at the left-end of a row 
+            P.oldindex = P.index
+            P.index = P.index +m-1
+
+            while list[P.index+1] == nil do
+                P.oldindex = P.index
+                P.index = P.index -1
+            end
+        else
+            P.oldindex = P.index
+            P.index = P.index -1
+
+            while list[P.index+1] == nil do
+                if P.index % m == 0 then     -- we are at the left-end of a row 
+                    P.oldindex = P.index
+                    P.index = P.index -1 + m
+                else                
+                    P.oldindex = P.index
+                    P.index = P.index -1
+                end
+            end   
+        end
+    end    
+
+    cout(0, P.oldindex)
+    cout(0, P.index)
+
+end
+
+
+
+
Index: /code/branches/menu/data/gui/scripts/MainMenu.lua
===================================================================
--- /code/branches/menu/data/gui/scripts/MainMenu.lua	(revision 7662)
+++ /code/branches/menu/data/gui/scripts/MainMenu.lua	(revision 7663)
@@ -4,5 +4,51 @@
 P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
 
-P.index = 0
+P.buttonList = {}
+
+P.testArray = {}
+
+
+function P.onLoad()
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
+            ["function"]  = P.QuickGameTestButton_clicked
+    }
+    table.insert(P.buttonList,item)
+
+    item = {
+            ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"),
+            ["function"]  = P.SingleplayerButton_clicked
+    }
+    table.insert(P.buttonList,item)
+
+    item = {
+            ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"),
+            ["function"]  = P.MultiplayerButton_clicked
+    }
+    table.insert(P.buttonList,item)
+
+    item = {
+            ["button"] = winMgr:getWindow("orxonox/SettingsButton"),
+            ["function"]  = P.SettingsButton_clicked
+    }
+    table.insert(P.buttonList,item)
+
+    item = {
+            ["button"] = winMgr:getWindow("orxonox/CreditsButton"),
+            ["function"]  = P.CreditsButton_clicked
+    }
+    table.insert(P.buttonList,item)
+
+    item = {
+            ["button"] = winMgr:getWindow("orxonox/ExitButton"),
+            ["function"]  = P.ExitButton_clicked
+    }
+    table.insert(P.buttonList,item) 
+end
+
+function P.onShow()
+    P.oldindex = -2
+    P.index = -1
+end
 
 -- events for MainMenu
@@ -10,8 +56,4 @@
     hideAllMenuSheets()
     orxonox.execute("startGame")
-end
-
-function P.onShow()
-
 end
 
@@ -36,33 +78,42 @@
 end
 
-function P.onKeyPressed()
-    --local we = tolua.cast(e, "CEGUI::KeyEventArgs")
-    cout(0, code)
-    if code == "15" then
-        P.index = P.index + 1
-        local window = winMgr:getWindow("orxonox/MainMenuBackground")
-        if P.index == window:getChildCount() then
-            P.index = 1
-        end
-        local child = window:getChildAtIdx(P.index-1)
-        child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")
-        child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")
-        child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")
-    elseif code == "28" and P.index ~= 0 then
-        if P.index == 1 then
-            P.QuickGameTestButton_clicked()
-        elseif P.index == 2 then
-            P.SingleplayerButton_clicked()
-        elseif P.index == 3 then
-            P.MultiplayerButton_clicked()
-        elseif P.index == 4 then
-            P.SettingsButton_clicked()
-        elseif P.index == 5 then
-            P.CreditsButton_clicked()
-        elseif P.index == 6 then
-            P.ExitButton_clicked()
-        end
+
+--[[
+list = {}
+local item =
+{
+    ["button"] = buttonWindow,
+    ["function"]  = buttonFunction,
+}
+table.insert(list, item)
+item = list[i]
+
+for i,item in pairs(list) do
+    button = item["button"]
+end
+
+--]]
+--[[
+function createList()
+    list = {}
+
+    local j 
+    while j < P.loadAlong 
+        local item =
+        {
+            ["button"] = buttonWindow,
+            ["function"]  = buttonFunction,
+        }
+        table.insert(list, item)
     end
+
+--]]
+
+function P.onKeyPressed() 
+    cout(0,code)
+    buttonIteratorHelper(P.buttonList, code, P, 6, 1)
+    --indexTester(P.buttonList,code,P,6,1)
 end
 
 return P
+
Index: /code/branches/menu/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- /code/branches/menu/data/gui/scripts/MultiplayerMenu.lua	(revision 7662)
+++ /code/branches/menu/data/gui/scripts/MultiplayerMenu.lua	(revision 7663)
@@ -3,10 +3,33 @@
 local P = createMenuSheet("MultiplayerMenu")
 
+P.buttonList = {}
+
 function P.onLoad()
-    P.multiplayerMode = "startClient"
+    P.multiplayerMode = "startClient" 
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton2"),
+            ["function"]  = P.MultiplayerJoinButton_clicked
+    }
+    P.buttonList[1] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton2"),
+            ["function"]  = P.MultiplayerHostButton_clicked
+    }
+    P.buttonList[2] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/MultiplayerBackButton"),
+            ["function"]  = P.MultiplayerBackButton_clicked
+    }
+    P.buttonList[4] = item
+
 end
 
 function P.onShow()
     P.showServerList()
+    P.oldindex = -2
+    P.index = -1
 end
 
@@ -109,4 +132,10 @@
 end
 
+function P.onKeyPressed() 
+    cout(0,code)
+    buttonIteratorHelper(P.buttonList, code, P, 2, 2)
+    --indexTester(P.buttonList,code,P,2,3)
+end
+
 return P
 
Index: /code/branches/menu/data/gui/scripts/SettingsMenu.lua
===================================================================
--- /code/branches/menu/data/gui/scripts/SettingsMenu.lua	(revision 7662)
+++ /code/branches/menu/data/gui/scripts/SettingsMenu.lua	(revision 7663)
@@ -3,4 +3,47 @@
 local P = createMenuSheet("SettingsMenu")
 P.loadAlong = { "ControlsMenu", "AudioMenu", "GraphicsMenu" }
+
+P.buttonList = {}
+
+function P.onLoad()
+    --"Gameplay" and "Multiplayer Options" are not integrated in the list
+    
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"),
+            ["function"]  = P.SettingsGraphicsButton_clicked
+    }
+    P.buttonList[2] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/AudioButton"),
+            ["function"]  = P.SettingsAudioButton_clicked
+    }
+    P.buttonList[4] = item
+
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"),
+            ["function"]  = P.SettingsControlsButton_clicked
+    }
+    P.buttonList[5] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"),
+            ["function"]  = P.SettingsMiscellaneousButton_clicked
+    }
+    P.buttonList[6] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"),
+            ["function"]  = P.SettingsBackButton_clicked
+    }
+    P.buttonList[7] = item
+
+end
+
+function P.onShow()
+    P.oldindex = 3
+    P.index = 2
+end
 
 function P.SettingsGameplayButton_clicked(e)
@@ -32,4 +75,10 @@
 end
 
+function P.onKeyPressed() 
+    cout(0,code)
+    buttonIteratorHelper(P.buttonList, code, P, 4, 2)
+    --indexTester(P.buttonList,code,P,4,2)
+end
+
 return P
 
