// Simple callbacks. #include #include #include #include #include dcl_sub_(q_win, q::win) bol_mut_(onClose, ()); dcl_end bool q_win::onClose() { static uint clickCount = 0; ++clickCount; // closes on second attempt return 2 <= clickCount; } void onBtnClicked(q::pushbtn& btn, bool b) { static uint clickCountDown = 5; if (0 == clickCountDown) { // switch callback off btn.disConn(); return; } clickCountDown -= 1; btn.setText(btn.text() + "+"); } int main(int argc, pcstr argv[]) { q::app app(argc, argv, APP_NAME, nullptr, ORG_DOMAIN, nullptr); auto* win = new q_win; auto&& vb = win->verBoxl(); auto* btn = new q::pushbtn("Click Me"); vb.add(btn); btn->onClicked([=](bool b) { onBtnClicked(*btn, b); }); btn = new q::pushbtn("Close"); vb.add(btn); btn->onClicked([=](bool b) { win->close(); }); win->show(); app.exec(); } // eof