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