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 cdeb11b0f4

View File

@@ -761,6 +761,9 @@
// Handle mouse input // Handle mouse input
(when mouseMode (when mouseMode
(let [mousePos (FlxG.mouse.getScreenPosition controlCamera)] (let [mousePos (FlxG.mouse.getScreenPosition controlCamera)]
// Click outside of right-click menu
(when (and isRightClickMenu FlxG.mouse.justPressed !(.containsPoint (getScreenBounds) (FlxG.mouse.getScreenPosition)))
(hide))
// Click and hover on clickable text entries // Click and hover on clickable text entries
(controls.forEach ->text (controls.forEach ->text
(let [onClick (dictGet _actions text) (let [onClick (dictGet _actions text)
@@ -1101,6 +1104,7 @@
(-= xText.x xText.width))) (-= xText.x xText.width)))
(prop &mut :SimpleWindow rightClickMenu) (prop &mut :SimpleWindow rightClickMenu)
(prop &mut isRightClickMenu false)
(method :Void showRightClickMenu [:FlxSprite control :Map<String,Action> altActions] (method :Void showRightClickMenu [:FlxSprite control :Map<String,Action> altActions]
(hideTooltipText) (hideTooltipText)
@@ -1124,6 +1128,8 @@
->choice ->choice
((dictGet altActions (dictGet keysWithoutNumberMap choice)) control) ((dictGet altActions (dictGet keysWithoutNumberMap choice)) control)
(objectWith [choiceColor textColor xButton true] bgColor))] (objectWith [choiceColor textColor xButton true] bgColor))]
(set choiceWindow.isRightClickMenu true)
(set choiceWindow.mouseMode mouseMode)
(set rightClickMenu choiceWindow) (set rightClickMenu choiceWindow)
// set up choiceWindow with position where it should be etc // set up choiceWindow with position where it should be etc
(set choiceWindow.camera controlCamera) (set choiceWindow.camera controlCamera)