From 0c5186a37d70c24d29d70fe6c0b034b08d022c94 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 15 Aug 2022 01:28:42 +0600 Subject: [PATCH] add toggle closing confirmation button --- WebApp/src/jsMain/kotlin/main.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/WebApp/src/jsMain/kotlin/main.kt b/WebApp/src/jsMain/kotlin/main.kt index b317f5f..8adf3f7 100644 --- a/WebApp/src/jsMain/kotlin/main.kt +++ b/WebApp/src/jsMain/kotlin/main.kt @@ -125,6 +125,23 @@ fun main() { document.body ?.appendElement("p", {}) + document.body ?.appendElement("button") { + fun updateText() { + textContent = if (webApp.isClosingConfirmationEnabled) { + "Disable closing confirmation" + } else { + "Enable closing confirmation" + } + } + addEventListener("click", { + webApp.toggleClosingConfirmation() + updateText() + }) + updateText() + } ?: window.alert("Unable to load body") + + document.body ?.appendElement("p", {}) + webApp.apply { onThemeChanged { document.body ?.log("Theme changed: ${webApp.themeParams}")