// Simple callbacks. #include #pragma GCC diagnostic ignored "-Wunused-parameter" bool onWinClose(hWin win) { static uint clickCount = 0; ++clickCount; // closes on second attempt if (clickCount < 2) return false; return true; } void onBtnClicked(hBtn btn, bool b) { static uint clickCountDown = 5; if (0 == clickCountDown) { btn_disConn(btn); return; } clickCountDown -= 1; pstr s1 = btn_text(btn); pstr s2 = str_cat(s1, "+", 0); btn_setText(btn, s2); str_free(s2); str_free(s1); } void onCloseClicked(hWin win, bool b) { win_close(win); } int main(int argc, pcstr argv[]) { hApp app = app_make(argc, argv, APP_NAME, 0, ORG_DOMAIN, 0); hWin win = win_make(); x_cbVoidToBool cbOnClose = {win, onWinClose}; win_onClose(win, cbOnClose); hBoxl vb = win_verBoxl(win); hBtn btn = box_add(vb, btn_make("Click Me")); box_add(vb, btn); x_cbBool cbClicked = {btn, onBtnClicked}; btn_onClicked(btn, cbClicked); btn = box_add(vb, btn_make("Close")); box_add(vb, btn); x_cbBool cbClose = {win, onCloseClicked}; btn_onClicked(btn, cbClose); win_show(win, true); app_exec(app); app_free(&app); } // eof