From 0cbf6f8718340f37f112240604fb0b5e25eae032 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Aug 2020 14:31:07 -0700 Subject: [PATCH] Exit app on windows close. --- src/main/kotlin/com/beust/chip8/Main.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/chip8/Main.kt b/src/main/kotlin/com/beust/chip8/Main.kt index f6ce501..517a79b 100644 --- a/src/main/kotlin/com/beust/chip8/Main.kt +++ b/src/main/kotlin/com/beust/chip8/Main.kt @@ -3,6 +3,7 @@ package com.beust.chip8 import com.beust.jcommander.JCommander import com.beust.jcommander.Parameter import javafx.application.Application +import javafx.application.Platform import javafx.beans.property.SimpleBooleanProperty import javafx.beans.property.SimpleStringProperty import javafx.event.EventHandler @@ -97,6 +98,10 @@ class MyFxApp : Application() { } primaryStage.title = "CHIP-8" + primaryStage.onCloseRequest = EventHandler { + Platform.exit() + exitProcess(0) + } val url = this::class.java.classLoader.getResource("main.fxml") val loader = FXMLLoader(url) val res = url.openStream() @@ -190,7 +195,7 @@ class MyFxApp : Application() { try { val key = Integer.parseInt(event.code.char, 16) keyListener.onKey(key) - } catch(ex: NumberFormatException) { + } catch (ex: NumberFormatException) { println("Can't parse key " + event.code.char + ", ignoring") } }