| 188 | } |
| 189 | |
| 190 | void WindowTestClose::onWindowClose(EventCustom* e) |
| 191 | { |
| 192 | auto isClose = static_cast<bool*>(e->getUserData()); |
| 193 | if (isClose == nullptr) |
| 194 | return; |
| 195 | |
| 196 | // false prevents the window from closing |
| 197 | *isClose = false; |
| 198 | |
| 199 | this->stopActionByTag(1); |
| 200 | if (label != nullptr) |
| 201 | { |
| 202 | label->removeFromParent(); |
| 203 | label = nullptr; |
| 204 | } |
| 205 | |
| 206 | auto s = _director->getWinSize(); |
| 207 | label = Label::createWithTTF("Window close button callback!", "fonts/Marker Felt.ttf", 16.0f); |
| 208 | label->setPosition(s.width / 2, s.height / 2); |
| 209 | addChild(label); |
| 210 | |
| 211 | auto delay = DelayTime::create(3.0); |
| 212 | auto callFunc = CallFunc::create( |
| 213 | [this]() |
| 214 | { |
| 215 | if (label != nullptr) |
| 216 | { |
| 217 | label->removeFromParent(); |
| 218 | label = nullptr; |
| 219 | } |
| 220 | }); |
| 221 | auto sequence = Sequence::create(delay, callFunc, nullptr); |
| 222 | sequence->setTag(1); |
| 223 | this->runAction(sequence); |
| 224 | } |
| 225 | |
| 226 | #endif |
nothing calls this directly
no test coverage detected