fix keyboard shortcuts firing when typing text

This commit is contained in:
2022-08-29 16:13:54 +00:00
parent b456e2d2fd
commit 9eeb457040
2 changed files with 9 additions and 4 deletions

View File

@@ -117,6 +117,8 @@
(method startAdding [:EntryType type] (method startAdding [:EntryType type]
(set typeAdding type) (set typeAdding type)
(set entryNameText (new FlxInputText 0 0 FlxG.width "" textSize true)) (set entryNameText (new FlxInputText 0 0 FlxG.width "" textSize true))
(when entryWindow
(set entryWindow.keyboardEnabled false))
(set entryNameText.cameras [uiCamera]) (set entryNameText.cameras [uiCamera])
(set entryNameText.hasFocus true) (set entryNameText.hasFocus true)
(add entryNameText)) (add entryNameText))
@@ -128,7 +130,9 @@
(model.addEntry typeAdding [entryNameText.text]) (model.addEntry typeAdding [entryNameText.text])
(refreshModel) (refreshModel)
(entryNameText.kill) (entryNameText.kill)
(set entryNameText null)) (set entryNameText null)
(when entryWindow
(set entryWindow.keyboardEnabled true)))
(true (true
(startAdding Todo)))) (startAdding Todo))))
(when FlxG.keys.justPressed.UP (when FlxG.keys.justPressed.UP
@@ -173,7 +177,6 @@
false) false)
(prop &mut :FlxTypedGroup<FlxText> logTexts (new FlxTypedGroup)) (prop &mut :FlxTypedGroup<FlxText> logTexts (new FlxTypedGroup))
(prop &mut :FlxKeyShortcutHandler<Entry> shortcutHandler null)
(prop &mut :HabitModel model null) (prop &mut :HabitModel model null)
@@ -216,7 +219,6 @@
(method :Void setModel [m &opt :RewardFile currentRewardFile] (method :Void setModel [m &opt :RewardFile currentRewardFile]
(set model m) (set model m)
(set shortcutHandler (new FlxKeyShortcutHandler))
(let [p (m.totalPoints) (let [p (m.totalPoints)
&mut i 0 &mut i 0

View File

@@ -2,6 +2,8 @@
(var &mut textSize 16) (var &mut textSize 16)
(var :kiss.List<SimpleWindow> windowStack []) (var :kiss.List<SimpleWindow> windowStack [])
(prop &mut keyboardEnabled true)
// TODO tooltip support with left-click and right-click action // TODO tooltip support with left-click and right-click action
// icons and explanations // icons and explanations
@@ -96,7 +98,8 @@
(super.update elapsed) (super.update elapsed)
(set otherIsSelected false) (set otherIsSelected false)
(when (= (last windowStack) this) (when (= (last windowStack) this)
(keyHandler.update) (when keyboardEnabled
(keyHandler.update))
// Handle mouse input // Handle mouse input
(let [camera (first (or cameras [])) (let [camera (first (or cameras []))
mousePos (FlxG.mouse.getScreenPosition camera)] mousePos (FlxG.mouse.getScreenPosition camera)]