From 909e444b5ff7175b646521c7969dceb735be9b46 Mon Sep 17 00:00:00 2001 From: David Botton Date: Fri, 2 Sep 2022 16:58:48 -0400 Subject: [PATCH] added js api clogframe_quit() --- clogframe/clogframe.cpp | 6 ++++++ demos/01-demo.lisp | 1 + 2 files changed, 7 insertions(+) diff --git a/clogframe/clogframe.cpp b/clogframe/clogframe.cpp index 33dd384..146d794 100644 --- a/clogframe/clogframe.cpp +++ b/clogframe/clogframe.cpp @@ -2,10 +2,16 @@ #include #include #include "webview.h" + int main(int argc,char* argv[]) { webview::webview w(true, nullptr); + webview::webview *w2 = &w; w.set_title(argv[1]); w.set_size(std::stoi(argv[3]), std::stoi(argv[4]), WEBVIEW_HINT_NONE); + w.bind("clogframe_quit", [w2](std::string s) -> std::string { + w2->terminate(); + return ""; + }); std::ostringstream o; o << "http://127.0.0.1:" << argv[2]; w.navigate(o.str()); diff --git a/demos/01-demo.lisp b/demos/01-demo.lisp index 5a776c1..dec9948 100644 --- a/demos/01-demo.lisp +++ b/demos/01-demo.lisp @@ -180,6 +180,7 @@ ;; When *app-mode* set only run the game once and then shutdown the app (when *app-mode* (sleep 2) ;; let end music play + (js-execute body "clogframe_quit()") ;; does nothing if not in clogframe (clog:shutdown) (uiop:quit)))