paste into NAT text input

This commit is contained in:
2022-07-06 21:35:30 +00:00
parent 24e806d4fd
commit 21dfb34baf
2 changed files with 20 additions and 9 deletions

View File

@@ -22,6 +22,8 @@ using kiss_flixel.CameraTools;
import kiss_tools.KeyShortcutHandler; import kiss_tools.KeyShortcutHandler;
import kiss_tools.FlxKeyShortcutHandler; import kiss_tools.FlxKeyShortcutHandler;
import nat.systems.PlaygroundSystem; import nat.systems.PlaygroundSystem;
import flash.desktop.Clipboard;
import flash.desktop.ClipboardFormats;
@:build(kiss.Kiss.build()) @:build(kiss.Kiss.build())
class PlayState extends FlxState implements ArchiveUI {} class PlayState extends FlxState implements ArchiveUI {}

View File

@@ -115,16 +115,25 @@
(when sh.currentMap (when sh.currentMap
(sh.update)) (sh.update))
(when (and FlxG.keys.justPressed.V FlxG.keys.pressed.CONTROL)
(when (and textInput textInput.hasFocus)
(whenLet [text (Clipboard.generalClipboard.getData ClipboardFormats.TEXT_FORMAT)]
(when (textInput.text.endsWith "v")
(set textInput.text (substr textInput.text 0 -1)))
(+= textInput.text text)
(set textInput.caretIndex textInput.text.length))))
(when FlxG.keys.justPressed.ESCAPE (when FlxG.keys.justPressed.ESCAPE
(if (and textInput textInput.hasFocus) (cond
{ ((and textInput textInput.hasFocus)
(set textInput.callback null) (set textInput.callback null)
(hideUI textInput) (hideUI textInput)
// This part is hacky... // This part is hacky...
(set lastUI textInputLabel) (set lastUI textInputLabel)
(hideUI textInputLabel) (hideUI textInputLabel))
} (sh.currentMap
(Sys.exit 0))) (sh.cancel))
(true (Sys.exit 0))))
// Press ENTER to type a command to run // Press ENTER to type a command to run
(when (and !textInput FlxG.keys.justPressed.ENTER) (when (and !textInput FlxG.keys.justPressed.ENTER)