fully show last control in vertical SimpleWindow

This commit is contained in:
2023-07-10 13:57:40 -06:00
parent 3879945659
commit 192ed4e49e
2 changed files with 14 additions and 4 deletions

View File

@@ -14,7 +14,7 @@
->:Void choice ->:Void choice
(case choice (case choice
("Vertical" ("Vertical"
null) (verticalMenu))
("Menu" ("Menu"
(subMenu)) (subMenu))
("Quit" ("Quit"
@@ -41,5 +41,14 @@
[=>B "tab"]) [=>B "tab"])
(window.show))) (window.show)))
(method verticalMenu []
(let [window (new SimpleWindow "Vertical Menu" true)]
(set window.onClose ->:Void {(window.hide)(showMenu)})
(window.enableVerticalScrolling)
(doFor num (range 50)
(window.makeText "$num"))
(window.enableGamepadInput true)
(window.show)))
(method &override :Void update [:Float elapsed] (method &override :Void update [:Float elapsed]
(super.update elapsed)) (super.update elapsed))

View File

@@ -115,7 +115,7 @@
:String upKey (or _upKey defaultUpKey) :String upKey (or _upKey defaultUpKey)
:String downKey (or _downKey defaultDownKey) :String downKey (or _downKey defaultDownKey)
:String enterKey (or _enterKey defaultEnterKey) :String enterKey (or _enterKey defaultEnterKey)
:ShortcutAction onClose _onClose &mut :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, // The xHandler exists so that when keyboard shortcuts are disabled,
@@ -282,8 +282,9 @@
(apply or (for _ (range SCROLL_LINES) (_scrollDown)))) (apply or (for _ (range SCROLL_LINES) (_scrollDown))))
(method :Bool _scrollDown [] (method :Bool _scrollDown []
(let [:kiss.List<FlxSprite> controls (_nonUIControls)] (let [:kiss.List<FlxSprite> controls (_nonUIControls)
(when (< .y (last controls) _height) lastControl (last controls)]
(when (< (+ lastControl.y lastControl.height) _height)
(return false)) (return false))
(doFor c controls (doFor c controls
(-= c.y c.height) (-= c.y c.height)