Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2011, 12:47:57 AM (13 years ago)
Author:
landauf
Message:

implemented new keyboard control of menu buttons with these new features:

  • more intuitive placement of buttons in table (row/column format instead of linear index)
  • no need to overwrite onShow() and onKeyPressed() functions, no need for P.buttonList
  • highlights the selected button in a different layout than mouse hovering
  • remembers the selection while moving through the menu hierarchy, but resets it if the menu is closed
  • allows preselected button (for example "Yes" in decision popup)
  • when opening a menu, the first selected button is not always the upper left, but instead depends on the pressed key (e.g. the 'up' key selects the button at the bottom, while the 'down' key selects the button at the top. once a button is selected, the keys behave as usual)

+ fixed wrong callback function in ingame menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability/data/gui/scripts/DecisionPopup.lua

    r7726 r7922  
    33local P = createMenuSheet("DecisionPopup")
    44
    5 P.buttonList = {}
    6 
    7 function P.onShow()
    8     --indices to iterate through buttonlist
    9     P.oldindex = -2
    10     P.index = -1
    11 end
    12 
    135function P.onLoad()
    146
    157    --button are arranged in a 1x2 matrix
    16     local item = {
     8    P:initButtons(1, 2)
     9
     10    P:setButton(1, 1, {
    1711            ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_yes"),
    18             ["function"]  = P.button_yes
    19     }
    20     P.buttonList[1] = item
     12            ["callback"]  = P.button_yes
     13    })
    2114
    22     local item = {
     15    P:setButton(1, 2, {
    2316            ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_no"),
    24             ["function"]  = P.button_no
    25     }
    26     P.buttonList[2] = item
     17            ["callback"]  = P.button_no
     18    })
     19end
    2720
     21function P.onShow()
     22    P:setSelection(1, 1)
    2823end
    2924
     
    5146end
    5247
    53 function P.onKeyPressed()
    54     buttonIteratorHelper(P.buttonList, code, P, 1, 2)
    55 end
    56 
    5748return P
    5849
Note: See TracChangeset for help on using the changeset viewer.