Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct OpenClose : UINode
- {
- void Render(UIContainer* ctx) override
- {
- ctx->PushBox();
- cb = ctx->Element<UICheckbox>();
- cb->SetValue(open);
- openBtn = ctx->Element<UIButton>();
- openBtn->SetText("Open");
- closeBtn = ctx->Element<UIButton>();
- closeBtn->SetText("Close");
- if (open)
- {
- ctx->PushBox();
- ctx->Text("It is open!");
- ctx->Pop();
- }
- ctx->Pop();
- }
- void OnEvent(UIEvent& e) override
- {
- if (e.type == UIEventType::Click)
- {
- if (e.target == openBtn || e.target == closeBtn)
- {
- open = e.target == openBtn;
- e.context->Rebuild(this);
- }
- }
- if (e.type == UIEventType::Change)
- {
- if (e.target == cb)
- {
- open = cb->GetValue();
- e.context->Rebuild(this);
- }
- }
- }
- bool open = false;
- UICheckbox* cb;
- UIButton* openBtn;
- UIButton* closeBtn;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement