From e6228eb3c188ea75f06d997c91a5b8782dfdca0b Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 7 Jul 2022 02:31:19 +0000 Subject: [PATCH] NAT playground confirm ESCAPE for exit --- .../source/PlayState.kiss | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/projects/nat-flixel-desktop-playground/source/PlayState.kiss b/projects/nat-flixel-desktop-playground/source/PlayState.kiss index 59696e97..b7cec32a 100644 --- a/projects/nat-flixel-desktop-playground/source/PlayState.kiss +++ b/projects/nat-flixel-desktop-playground/source/PlayState.kiss @@ -108,6 +108,7 @@ (method :Void hidePrefixMap [] (clearUI)) +(prop &mut :Bool confirmQuit false) (defAlias &ident sh (cast shortcutHandler FlxKeyShortcutHandler)) (method &override :Void update [:Float elapsed] (super.update elapsed) @@ -131,19 +132,22 @@ // This part is hacky... (set lastUI textInputLabel) (hideUI textInputLabel)) - (sh.currentMap + (~sh.currentMap (sh.cancel)) - (true (Sys.exit 0)))) + (confirmQuit + (Sys.exit 0)) + (true + (displayMessage "Really quit?") + (set confirmQuit true)))) // Press ENTER to type a command to run (when (and !textInput FlxG.keys.justPressed.ENTER) + (set confirmQuit false) (typeCommand)) (when (and textInput !textInput.alive) (set textInput null)) - // Press ESCAPE to clear the UI and cancel any input - (when FlxG.keys.justPressed.ESCAPE - (clearUI)) + // Scroll the UI with the mouse: (var UI_SCROLL_FACTOR 2) @@ -167,6 +171,7 @@ // Don't check keys that can be used in shortcuts outside this block: (unless (or sh.currentMap (and textInput textInput.hasFocus)) (when FlxG.keys.justPressed.SEMICOLON + (set confirmQuit false) (sh.start) (return)) // +/- keys to change an entry's z