diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index 33c25de4..5e6797ba 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -145,7 +145,7 @@ (otherwise "series of steps for completing this task"))) (localVar title "Add a label for this ${typeDescriptor}, or use SHIFT+ENTER to add a ${multipleLabelDescriptor}:") - (set entryCreationWindow (new SimpleWindow title null null 0.9 0.9 true xKey backToEntryWindow)) + (set entryCreationWindow (new SimpleWindow title null null 0.9 0.9 true xKey leftKey rightKey backToEntryWindow)) // TODO don't allow /, +, $, * (set entryNameText (new KissInputText 0 0 FlxG.width "" textSize true)) (entryCreationWindow.addControl entryNameText) @@ -326,7 +326,7 @@ ((Some "Task") (createTaskEntry)) ((Some "Bonus") (createBonusEntry)) (otherwise (throw "nonexistent choice"))) - null null FlxColor.LIME 0.9 0.9 true xKey backToEntryWindow)))) + null null FlxColor.LIME 0.9 0.9 true xKey leftKey rightKey backToEntryWindow)))) (_makeText "Choose Top-Priority habits and tasks" 0 ->_ (defAndCall method choosePriorities @@ -345,7 +345,7 @@ (choosePriorities) }) } - null null FlxColor.WHITE 0.9 0.9 true (defAndReturn prop xKey "escape") backToEntryWindow true)] + null null FlxColor.WHITE 0.9 0.9 true (defAndReturn prop xKey "escape") (defAndReturn prop leftKey "left") (defAndReturn prop rightKey "right") backToEntryWindow true)] (pw.show cameraColumn) (set priorityWindow pw)))) @@ -356,7 +356,7 @@ (let [editWindow (SimpleWindow.promptForChoice "Edit which habit/task's labels?" (model.allUndeletedEntries) editLabels - null null FlxColor.WHITE 0.9 0.9 true xKey backToEntryWindow true)] + null null FlxColor.WHITE 0.9 0.9 true xKey leftKey rightKey backToEntryWindow true)] (set entryEditWindow editWindow)))) (let [showOrHide (if model.showLowerPriority "Hide" "Show")] @@ -378,7 +378,7 @@ (refreshModel) (entryWindow.show) } - null null FlxColor.WHITE 0.9 0.9 true xKey backToEntryWindow true)] + null null FlxColor.WHITE 0.9 0.9 true xKey leftKey rightKey backToEntryWindow true)] (set entryDeletionWindow delWindow)))) (when (= rewardFileIndex (- m.rewardFiles.length 1)) @@ -832,7 +832,7 @@ idxArr) dayText ->idx "$(nth days idx): $(if (nth daysEnabled idx) "yes" "no")" dayColor ->idx (if (nth daysEnabled idx) (FlxColor.LIME.getDarkened) FlxColor.GRAY) - window (new SimpleWindow prompt null null width height true xKey backToEntryWindow)] + window (new SimpleWindow prompt null null width height true xKey leftKey rightKey backToEntryWindow)] (localFunction refreshWindow [] (window.clearControls) (doFor [idx day] (enumerate days) @@ -859,7 +859,7 @@ (createToggleIndicesType false Monthly (cast texts) 28 "Which days of the month?" 0.9 0.9))) (method createIntervalEntry [] - (set entryCreationWindow (new SimpleWindow "After finishing this habit, how many days do you wait before doing it again?" null null 0.9 0.9 true xKey backToEntryWindow)) + (set entryCreationWindow (new SimpleWindow "After finishing this habit, how many days do you wait before doing it again?" null null 0.9 0.9 true xKey leftKey rightKey backToEntryWindow)) (set entryNameText (new KissInputText 0 0 FlxG.width "" textSize true)) (set addingLabels false) (entryCreationWindow.addControl entryNameText) @@ -913,7 +913,7 @@ [s piece]))))) (method editLabels [:Entry e] - (let [window (new SimpleWindow "Editing labels" null null 0.9 0.9 true xKey backToEntryWindow) + (let [window (new SimpleWindow "Editing labels" null null 0.9 0.9 true xKey leftKey rightKey backToEntryWindow) inputTexts (for l e.labels // TODO don't allow /, +, $, * (new KissInputText 0 0 FlxG.width l.label textSize true))] diff --git a/projects/kiss-flixel/src/kiss_flixel/SimpleWindow.kiss b/projects/kiss-flixel/src/kiss_flixel/SimpleWindow.kiss index ccf9515f..85865a3f 100644 --- a/projects/kiss-flixel/src/kiss_flixel/SimpleWindow.kiss +++ b/projects/kiss-flixel/src/kiss_flixel/SimpleWindow.kiss @@ -18,6 +18,7 @@ :Float percentWidth :Float percentHeight :Bool _xButton :String _xKey + :String _leftKey :String _rightKey :ShortcutAction _onClose] [:String title (or _title "") @@ -28,9 +29,13 @@ &mut :FlxColor textColor (or _textColor FlxColor.WHITE) :Bool xButton ?_xButton :String xKey _xKey + :String leftKey _leftKey + :String rightKey _rightKey :ShortcutAction onClose _onClose :FlxTypedGroup controls (new FlxTypedGroup) :FlxKeyShortcutHandler keyHandler (new FlxKeyShortcutHandler) + // The xHandler exists so that when keyboard shortcuts are disabled, + // UI key controls are still available. it also handles left and right. :FlxKeyShortcutHandler xHandler (new FlxKeyShortcutHandler)] (super 0 0) @@ -142,6 +147,8 @@ (dictSet _colors ftext ftext.color) (dictSet _actions ftext ->:Void _ (scrollLeft)) (set leftText ftext)) + (when leftKey + (xHandler.registerItem "{${leftKey}}" scrollLeft)) (let [ftext (new FlxText width height 0 "->" textSize)] (set ftext.cameras [controlCamera]) (-= ftext.x ftext.width) @@ -151,6 +158,8 @@ (controls.add ftext) (dictSet _actions ftext ->:Void _ (scrollRight)) (set rightText ftext)) + (when rightKey + (xHandler.registerItem "{${rightKey}}" scrollRight)) (refreshColumnTexts) (set hasScrollArrows true)) @@ -299,9 +308,11 @@ :Float percentHeight :Bool xButton :String xKey + :String leftKey + :String rightKey :ShortcutAction onClose :Bool noShortcuts] - (let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight xButton xKey onClose) + (let [window (new SimpleWindow prompt bgColor titleColor percentWidth percentHeight xButton xKey leftKey rightKey onClose) choiceColor (or choiceColor titleColor FlxColor.WHITE)] (doFor choice choices (window.makeText (Std.string choice) choiceColor