clicking outside of right-click menu, get rid of it

This commit is contained in:
2025-12-18 20:25:26 -06:00
parent f11a32a149
commit 105b629cb9

View File

@@ -26,6 +26,8 @@
(prop :FlxSprite selectionMarker)
(var &mut :FlxSprite defaultSelectionMarker)
(prop &mut firstFrame true)
(prop &mut :Int _selectedIndex -1)
(prop :Int selectedIndex (property get set))
(method get_selectedIndex [] _selectedIndex)
@@ -729,7 +731,7 @@
(prop &mut :Bool mouseMode false)
(prop &mut otherIsSelected false)
(method &override update [:Float elapsed]
(method &override :Void update [:Float elapsed]
(super.update elapsed)
(set justPressedUIButton false)
(set otherIsSelected false)
@@ -759,8 +761,12 @@
(set mouseMode false))
// Handle mouse input
// Click outside of right-click menu
(when (and isRightClickMenu !firstFrame (or FlxG.mouse.justPressed FlxG.mouse.justPressedRight) !(.containsPoint (getScreenBounds) (FlxG.mouse.getScreenPosition)))
(hide))
(when mouseMode
(let [mousePos (FlxG.mouse.getScreenPosition controlCamera)]
// Click and hover on clickable text entries
(controls.forEach ->text
(let [onClick (dictGet _actions text)
@@ -804,7 +810,8 @@
(hideTooltipText)
// Click anywhere else to take focus away from text boxes
(when FlxG.mouse.justPressed
(inputTexts.forEach ->text (set text.hasFocus false))))))))
(inputTexts.forEach ->text (set text.hasFocus false))))))
(set firstFrame false)))
(function &private :SimpleWindow notify [:String message
:Void->Void onDismiss
@@ -1101,6 +1108,7 @@
(-= xText.x xText.width)))
(prop &mut :SimpleWindow rightClickMenu)
(prop &mut isRightClickMenu false)
(method :Void showRightClickMenu [:FlxSprite control :Map<String,Action> altActions]
(hideTooltipText)
@@ -1124,6 +1132,8 @@
->choice
((dictGet altActions (dictGet keysWithoutNumberMap choice)) control)
(objectWith [choiceColor textColor xButton true] bgColor))]
(set choiceWindow.isRightClickMenu true)
(set choiceWindow.mouseMode mouseMode)
(set rightClickMenu choiceWindow)
// set up choiceWindow with position where it should be etc
(set choiceWindow.camera controlCamera)