Last change
on this file since 11073 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
|
Rev | Line | |
---|
[6145] | 1 | -- DecisionPopup.lua |
---|
| 2 | |
---|
[6746] | 3 | local P = createMenuSheet("DecisionPopup") |
---|
[6145] | 4 | |
---|
[7726] | 5 | function P.onLoad() |
---|
| 6 | |
---|
| 7 | --button are arranged in a 1x2 matrix |
---|
[7922] | 8 | P:setButton(1, 1, { |
---|
[7726] | 9 | ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_yes"), |
---|
[7922] | 10 | ["callback"] = P.button_yes |
---|
| 11 | }) |
---|
[7726] | 12 | |
---|
[7922] | 13 | P:setButton(1, 2, { |
---|
[7726] | 14 | ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_no"), |
---|
[7922] | 15 | ["callback"] = P.button_no |
---|
| 16 | }) |
---|
| 17 | end |
---|
[7726] | 18 | |
---|
[7922] | 19 | function P.onShow() |
---|
| 20 | P:setSelection(1, 1) |
---|
[7726] | 21 | end |
---|
| 22 | |
---|
[6145] | 23 | function P.setCallback(functionPtr) |
---|
| 24 | P.functionPtr = functionPtr |
---|
| 25 | end |
---|
| 26 | |
---|
| 27 | function P.setText( text ) |
---|
| 28 | winMgr:getWindow("orxonox/DecisionPopup_text"):setText( text ) |
---|
| 29 | end |
---|
| 30 | |
---|
| 31 | -- events for ingamemenu |
---|
| 32 | function P.button_yes(e) |
---|
| 33 | if P.functionPtr ~= nil then |
---|
| 34 | P.functionPtr(true) |
---|
| 35 | end |
---|
[6746] | 36 | hideMenuSheet("DecisionPopup") |
---|
[6145] | 37 | end |
---|
| 38 | |
---|
| 39 | function P.button_no(e) |
---|
| 40 | if P.functionPtr ~= nil then |
---|
| 41 | P.functionPtr(false) |
---|
| 42 | end |
---|
[6746] | 43 | hideMenuSheet("DecisionPopup") |
---|
[6145] | 44 | end |
---|
| 45 | |
---|
| 46 | return P |
---|
| 47 | |
---|
Note: See
TracBrowser
for help on using the repository browser.