TDME2 1.9.121
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUIContextMenuController.cpp
Go to the documentation of this file.
2
3#include <string>
4
5#include <tdme/tdme.h>
13#include <tdme/gui/GUI.h>
17
18using std::to_string;
19
27using tdme::gui::GUI;
31
32GUIContextMenuController::GUIContextMenuController(GUINode* node)
34{
35}
36
38{
39 //
40 GUIElementController::initialize();
41}
42
44{
45 GUIElementController::dispose();
46}
47
49{
50}
51
53{
54 vector<GUINode*> childControllerNodes;
55 menuItemControllers.clear();
56 required_dynamic_cast<GUIParentNode*>(node)->getChildControllerNodes(childControllerNodes);
57 for (auto i = 0; i < childControllerNodes.size(); i++) {
58 auto childControllerNode = childControllerNodes[i];
59 auto childController = childControllerNode->getController();
60 auto menuItemController = dynamic_cast<GUIContextMenuItemController*>(childController);
61 if (menuItemController != nullptr) {
62 menuItemControllers.push_back(menuItemController);
63 }
64 }
65}
66
68{
69 if (selectedMenuItemControllerIdx == -1) return;
70 if (menuItemControllers.empty() == true) return;
72}
73
75{
77 if (menuItemControllers.empty() == true) return;
79 selectNext();
80}
81
83{
85 if (menuItemControllers.empty() == true) return;
86
87 auto disabledItems = 0;
88 while (disabledItems < menuItemControllers.size()) {
93 disabledItems++;
94 }
95
96 if (disabledItems == menuItemControllers.size()) {
98 return;
99 }
100
102}
103
105{
107 if (menuItemControllers.empty() == true) return;
109
110 auto disabledItems = 0;
111 while (disabledItems < menuItemControllers.size()) {
116 disabledItems++;
117 }
118
119 if (disabledItems == menuItemControllers.size()) {
121 return;
122 }
123
125
127{
129 if (selectedMenuItemControllerIdx == -1) return;
130 menuItemControllers[selectedMenuItemControllerIdx]->handleKeyboardEvent(event);
131}
132
134{
135 GUIElementController::handleMouseEvent(node, event);
136}
137
139{
140 GUIElementController::handleKeyboardEvent(event);
141 if (event->isProcessed() == true) return;
142 switch (event->getKeyCode()) {
143 case GUIKeyboardEvent::KEYCODE_UP: {
144 event->setProcessed(true);
145 if (event->getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
147 }
148 }
149 break;
150 case GUIKeyboardEvent::KEYCODE_DOWN: {
151 event->setProcessed(true);
152 if (event->getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
153 selectNext();
154 }
155 }
156 break;
157 }
158}
159
161{
162 GUIElementController::tick();
163}
164
166{
167}
168
170{
171}
172
174{
175 return true;
176}
177
179{
180 value.reset();
181 return value;
182}
183
185{
187}
188
192}
GUI module class.
Definition: GUI.h:66
void initialize() override
Initialize controller after element has been created.
void handleKeyboardEvent(GUIKeyboardEvent *event) override
Handle keyboard event.
void handleCurrentMenuItemKeyboardEvent(GUIKeyboardEvent *event)
Handle current menu item keyboard event.
void determineMenuItemControllers()
Determine menu item controllers.
void setValue(const MutableString &value) override
Set value.
void handleMouseEvent(GUINode *node, GUIMouseEvent *event) override
Handle mouse event.
void tick() override
Tick method will be executed once per frame.
vector< GUIContextMenuItemController * > menuItemControllers
GUI node base class.
Definition: GUINode.h:63
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:43
Console class.
Definition: Console.h:26
Mutable string class.
Definition: MutableString.h:16
MutableString & reset()
Reset.
String tools class.
Definition: StringTools.h:20