stop key shortcut input when simple window textbox is activated
This commit is contained in:
@@ -5,6 +5,7 @@ import kiss.List;
|
|||||||
import flixel.FlxG;
|
import flixel.FlxG;
|
||||||
import flixel.FlxCamera;
|
import flixel.FlxCamera;
|
||||||
import flixel.ui.FlxButton;
|
import flixel.ui.FlxButton;
|
||||||
|
import flixel.addons.ui.FlxInputText;
|
||||||
import flixel.text.FlxText;
|
import flixel.text.FlxText;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
import flixel.util.FlxColor;
|
import flixel.util.FlxColor;
|
||||||
|
@@ -30,7 +30,8 @@
|
|||||||
:String xKey _xKey
|
:String xKey _xKey
|
||||||
: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)
|
||||||
|
:FlxKeyShortcutHandler<ShortcutAction> xHandler (new FlxKeyShortcutHandler)]
|
||||||
|
|
||||||
(super 0 0)
|
(super 0 0)
|
||||||
(when defaultCamera (set this.cameras [defaultCamera]))
|
(when defaultCamera (set this.cameras [defaultCamera]))
|
||||||
@@ -56,12 +57,22 @@
|
|||||||
(when title
|
(when title
|
||||||
(makeText title null))
|
(makeText title null))
|
||||||
|
|
||||||
(set keyHandler.onBadKey ->:Void [key context] (print "bad key $key in context $context")) // TODO do SOMETHING like visual/audio bell, cancel and restart
|
(set keyHandler.onBadKey ->:Void [key context]
|
||||||
|
(unless (= key xKey)
|
||||||
|
(print "bad key $key in context $context"))) // TODO do SOMETHING like visual/audio bell, cancel and restart
|
||||||
(set keyHandler.onSelectItem
|
(set keyHandler.onSelectItem
|
||||||
->:Void [:ShortcutAction a] {
|
->:Void [:ShortcutAction a] {
|
||||||
(a)
|
(a)
|
||||||
(keyHandler.start)
|
(keyHandler.start)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(set xHandler.cancelKey null)
|
||||||
|
(set xHandler.onBadKey ->:Void [key context] 0)
|
||||||
|
(set xHandler.onSelectItem
|
||||||
|
->:Void [:ShortcutAction a] {
|
||||||
|
(a)
|
||||||
|
(xHandler.start)
|
||||||
|
})
|
||||||
|
|
||||||
(defAndCall method makeXControls
|
(defAndCall method makeXControls
|
||||||
(let [closeAction ->:Void {(hide)(when onClose (onClose))}]
|
(let [closeAction ->:Void {(hide)(when onClose (onClose))}]
|
||||||
@@ -78,14 +89,17 @@
|
|||||||
(when xKey
|
(when xKey
|
||||||
(when (= keyHandler.cancelKey xKey)
|
(when (= keyHandler.cancelKey xKey)
|
||||||
(set keyHandler.cancelKey null))
|
(set keyHandler.cancelKey null))
|
||||||
(keyHandler.registerItem "{${xKey}}" closeAction))))
|
(xHandler.registerItem "{${xKey}}" closeAction))))
|
||||||
|
|
||||||
// TODO show which shortcuts' prefixes are partially highlighted?
|
// TODO show which shortcuts' prefixes are partially highlighted?
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO could make a camera on the window so the controls are clipped by the camera
|
(prop :FlxTypedGroup<FlxInputText> inputTexts (new FlxTypedGroup))
|
||||||
|
|
||||||
(method addControl [:FlxSprite control]
|
(method addControl [:FlxSprite control]
|
||||||
|
|
||||||
|
(when (Std.isOfType control FlxInputText)
|
||||||
|
(inputTexts.add (cast control FlxInputText)))
|
||||||
(set control.cameras [controlCamera])
|
(set control.cameras [controlCamera])
|
||||||
(set control.x nextControlX)
|
(set control.x nextControlX)
|
||||||
(set control.y nextControlY)
|
(set control.y nextControlY)
|
||||||
@@ -157,6 +171,7 @@
|
|||||||
(set hasScrollArrows false)
|
(set hasScrollArrows false)
|
||||||
(_actions.clear)
|
(_actions.clear)
|
||||||
(controls.clear)
|
(controls.clear)
|
||||||
|
(inputTexts.clear)
|
||||||
(keyHandler.clear)
|
(keyHandler.clear)
|
||||||
(makeXControls)
|
(makeXControls)
|
||||||
(set nextControlX 0)
|
(set nextControlX 0)
|
||||||
@@ -170,6 +185,7 @@
|
|||||||
(FlxG.state.add controls)
|
(FlxG.state.add controls)
|
||||||
(windowStack.push this)
|
(windowStack.push this)
|
||||||
(keyHandler.start)
|
(keyHandler.start)
|
||||||
|
(xHandler.start)
|
||||||
(set _shown true)))
|
(set _shown true)))
|
||||||
|
|
||||||
(method :Void hide []
|
(method :Void hide []
|
||||||
@@ -179,6 +195,7 @@
|
|||||||
(FlxG.state.remove controls)
|
(FlxG.state.remove controls)
|
||||||
(windowStack.remove this)
|
(windowStack.remove this)
|
||||||
(keyHandler.cancel)
|
(keyHandler.cancel)
|
||||||
|
(xHandler.cancel)
|
||||||
(set _shown false)))
|
(set _shown false)))
|
||||||
|
|
||||||
(function getHighlighted [:FlxColor color &opt :Float amount]
|
(function getHighlighted [:FlxColor color &opt :Float amount]
|
||||||
@@ -194,7 +211,9 @@
|
|||||||
(set otherIsSelected false)
|
(set otherIsSelected false)
|
||||||
(when (= (last windowStack) this)
|
(when (= (last windowStack) this)
|
||||||
(when keyboardEnabled
|
(when keyboardEnabled
|
||||||
(keyHandler.update))
|
(unless (apply or (for textBox inputTexts.members textBox.hasFocus))
|
||||||
|
(keyHandler.update)))
|
||||||
|
(xHandler.update)
|
||||||
// Handle mouse input
|
// Handle mouse input
|
||||||
(let [mousePos (FlxG.mouse.getScreenPosition controlCamera)]
|
(let [mousePos (FlxG.mouse.getScreenPosition controlCamera)]
|
||||||
(controls.forEach ->text
|
(controls.forEach ->text
|
||||||
|
Reference in New Issue
Block a user