add leftKey, rightKey to SimpleWindow.

This commit is contained in:
2022-10-06 20:11:32 +00:00
parent ec38ef9108
commit bf51c8c0e8
2 changed files with 20 additions and 9 deletions

View File

@@ -145,7 +145,7 @@
(otherwise "series of steps for completing this task"))) (otherwise "series of steps for completing this task")))
(localVar title (localVar title
"Add a label for this ${typeDescriptor}, or use SHIFT+ENTER to add a ${multipleLabelDescriptor}:") "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 /, +, $, * // TODO don't allow /, +, $, *
(set entryNameText (new KissInputText 0 0 FlxG.width "" textSize true)) (set entryNameText (new KissInputText 0 0 FlxG.width "" textSize true))
(entryCreationWindow.addControl entryNameText) (entryCreationWindow.addControl entryNameText)
@@ -326,7 +326,7 @@
((Some "Task") (createTaskEntry)) ((Some "Task") (createTaskEntry))
((Some "Bonus") (createBonusEntry)) ((Some "Bonus") (createBonusEntry))
(otherwise (throw "nonexistent choice"))) (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 (_makeText "Choose Top-Priority habits and tasks" 0
->_ ->_
(defAndCall method choosePriorities (defAndCall method choosePriorities
@@ -345,7 +345,7 @@
(choosePriorities) (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) (pw.show cameraColumn)
(set priorityWindow pw)))) (set priorityWindow pw))))
@@ -356,7 +356,7 @@
(let [editWindow (SimpleWindow.promptForChoice "Edit which habit/task's labels?" (let [editWindow (SimpleWindow.promptForChoice "Edit which habit/task's labels?"
(model.allUndeletedEntries) (model.allUndeletedEntries)
editLabels 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)))) (set entryEditWindow editWindow))))
(let [showOrHide (if model.showLowerPriority "Hide" "Show")] (let [showOrHide (if model.showLowerPriority "Hide" "Show")]
@@ -378,7 +378,7 @@
(refreshModel) (refreshModel)
(entryWindow.show) (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)))) (set entryDeletionWindow delWindow))))
(when (= rewardFileIndex (- m.rewardFiles.length 1)) (when (= rewardFileIndex (- m.rewardFiles.length 1))
@@ -832,7 +832,7 @@
idxArr) idxArr)
dayText ->idx "$(nth days idx): $(if (nth daysEnabled idx) "yes" "no")" dayText ->idx "$(nth days idx): $(if (nth daysEnabled idx) "yes" "no")"
dayColor ->idx (if (nth daysEnabled idx) (FlxColor.LIME.getDarkened) FlxColor.GRAY) 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 [] (localFunction refreshWindow []
(window.clearControls) (window.clearControls)
(doFor [idx day] (enumerate days) (doFor [idx day] (enumerate days)
@@ -859,7 +859,7 @@
(createToggleIndicesType false Monthly (cast texts) 28 "Which days of the month?" 0.9 0.9))) (createToggleIndicesType false Monthly (cast texts) 28 "Which days of the month?" 0.9 0.9)))
(method createIntervalEntry [] (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 entryNameText (new KissInputText 0 0 FlxG.width "" textSize true))
(set addingLabels false) (set addingLabels false)
(entryCreationWindow.addControl entryNameText) (entryCreationWindow.addControl entryNameText)
@@ -913,7 +913,7 @@
[s piece]))))) [s piece])))))
(method editLabels [:Entry e] (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 inputTexts (for l e.labels
// TODO don't allow /, +, $, * // TODO don't allow /, +, $, *
(new KissInputText 0 0 FlxG.width l.label textSize true))] (new KissInputText 0 0 FlxG.width l.label textSize true))]

View File

@@ -18,6 +18,7 @@
:Float percentWidth :Float percentWidth
:Float percentHeight :Float percentHeight
:Bool _xButton :String _xKey :Bool _xButton :String _xKey
:String _leftKey :String _rightKey
:ShortcutAction _onClose] :ShortcutAction _onClose]
[:String title (or _title "") [:String title (or _title "")
@@ -28,9 +29,13 @@
&mut :FlxColor textColor (or _textColor FlxColor.WHITE) &mut :FlxColor textColor (or _textColor FlxColor.WHITE)
:Bool xButton ?_xButton :Bool xButton ?_xButton
:String xKey _xKey :String xKey _xKey
:String leftKey _leftKey
:String rightKey _rightKey
:ShortcutAction onClose _onClose :ShortcutAction onClose _onClose
:FlxTypedGroup<FlxSprite> controls (new FlxTypedGroup) :FlxTypedGroup<FlxSprite> controls (new FlxTypedGroup)
:FlxKeyShortcutHandler<ShortcutAction> keyHandler (new FlxKeyShortcutHandler) :FlxKeyShortcutHandler<ShortcutAction> 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<ShortcutAction> xHandler (new FlxKeyShortcutHandler)] :FlxKeyShortcutHandler<ShortcutAction> xHandler (new FlxKeyShortcutHandler)]
(super 0 0) (super 0 0)
@@ -142,6 +147,8 @@
(dictSet _colors ftext ftext.color) (dictSet _colors ftext ftext.color)
(dictSet _actions ftext ->:Void _ (scrollLeft)) (dictSet _actions ftext ->:Void _ (scrollLeft))
(set leftText ftext)) (set leftText ftext))
(when leftKey
(xHandler.registerItem "{${leftKey}}" scrollLeft))
(let [ftext (new FlxText width height 0 "->" textSize)] (let [ftext (new FlxText width height 0 "->" textSize)]
(set ftext.cameras [controlCamera]) (set ftext.cameras [controlCamera])
(-= ftext.x ftext.width) (-= ftext.x ftext.width)
@@ -151,6 +158,8 @@
(controls.add ftext) (controls.add ftext)
(dictSet _actions ftext ->:Void _ (scrollRight)) (dictSet _actions ftext ->:Void _ (scrollRight))
(set rightText ftext)) (set rightText ftext))
(when rightKey
(xHandler.registerItem "{${rightKey}}" scrollRight))
(refreshColumnTexts) (refreshColumnTexts)
(set hasScrollArrows true)) (set hasScrollArrows true))
@@ -299,9 +308,11 @@
:Float percentHeight :Float percentHeight
:Bool xButton :Bool xButton
:String xKey :String xKey
:String leftKey
:String rightKey
:ShortcutAction onClose :ShortcutAction onClose
:Bool noShortcuts] :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)] choiceColor (or choiceColor titleColor FlxColor.WHITE)]
(doFor choice choices (doFor choice choices
(window.makeText (Std.string choice) choiceColor (window.makeText (Std.string choice) choiceColor