Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/data/gui/scripts/DecisionPopup.lua @ 8777

Last change on this file since 8777 was 7928, checked in by landauf, 14 years ago

more improvements for keyboard control of menus:

  • added setSelectionNear(r, c) function which tries to select the button closest to the given row/column
  • no initialization required anymore, the button-table grows dynamically if new buttons are inserted
  • Property svn:eol-style set to native
File size: 960 bytes
Line 
1-- DecisionPopup.lua
2
3local P = createMenuSheet("DecisionPopup")
4
5function P.onLoad()
6
7    --button are arranged in a 1x2 matrix
8    P:setButton(1, 1, {
9            ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_yes"),
10            ["callback"]  = P.button_yes
11    })
12
13    P:setButton(1, 2, {
14            ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_no"),
15            ["callback"]  = P.button_no
16    })
17end
18
19function P.onShow()
20    P:setSelection(1, 1)
21end
22
23function P.setCallback(functionPtr)
24    P.functionPtr = functionPtr
25end
26
27function P.setText( text )
28    winMgr:getWindow("orxonox/DecisionPopup_text"):setText( text )
29end
30
31-- events for ingamemenu
32function P.button_yes(e)
33    if P.functionPtr ~= nil then
34        P.functionPtr(true)
35    end
36    hideMenuSheet("DecisionPopup")
37end
38
39function P.button_no(e)
40    if P.functionPtr ~= nil then
41        P.functionPtr(false)
42    end
43    hideMenuSheet("DecisionPopup")
44end
45
46return P
47
Note: See TracBrowser for help on using the repository browser.