mirror of
https://github.com/MeowLynxSea/ceditor.git
synced 2025-07-09 10:54:37 +00:00
为Menu增加了回调
This commit is contained in:
parent
ac4e01daf6
commit
e1fa660a7f
@ -27,6 +27,7 @@ private:
|
|||||||
MyVector<Option> options_;
|
MyVector<Option> options_;
|
||||||
int currentIndex_ = 0;
|
int currentIndex_ = 0;
|
||||||
Rect border_ = {0, 0, 0, 0};
|
Rect border_ = {0, 0, 0, 0};
|
||||||
|
void onOptionSelected(const std::string& id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Menu(int left, int top, RichText title, MyVector<MenuOption> options) : BaseComponent(left, top, 0, 0) { // set left/top to -1 to center the menu
|
Menu(int left, int top, RichText title, MyVector<MenuOption> options) : BaseComponent(left, top, 0, 0) { // set left/top to -1 to center the menu
|
||||||
@ -95,6 +96,8 @@ public:
|
|||||||
} else if(key == 80 + 256) {
|
} else if(key == 80 + 256) {
|
||||||
if(currentIndex_ == options_.size() - 1) return;
|
if(currentIndex_ == options_.size() - 1) return;
|
||||||
currentIndex_++;
|
currentIndex_++;
|
||||||
|
} else if(key == 13) { // enter
|
||||||
|
onOptionSelected(options_[currentIndex_].option.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < options_.size(); i++) {
|
for (int i = 0; i < options_.size(); i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user