From c1d1932e5da6ae4c32102e69b1f51e1edded4702 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Sat, 12 Dec 2020 16:42:39 +0000 Subject: [PATCH] Menubar auto-hide when leaving normal mouse mode. Patch from Michael Danilov: when auto-hide of the menubar is enabled, tigger the hide when we enter (via tab) mouse-flight-controls or mouse-look mode, since the menubar is not accessible in these modes anyway. --- Nasal/gui.nas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Nasal/gui.nas b/Nasal/gui.nas index 2c9915d5b..ccb26f062 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -1506,8 +1506,10 @@ setlistener(p ~ "aircraft-enable", func(n) set_precip(precip_ac = n.getValue()), # the autovisibility feature of the menubar # automatically show the menubar if the mouse is at the upper edge of the window -# the menubar is hidden by a binding to a LMB click in mode 0 in mice.xml +# the menubar is hidden by mouse mode != 0 and a binding to a LMB click in mode +# 0 in mice.xml var menubarAutoVisibilityListener = nil; +var menubarAutoVisibilityMouseModeListener = nil; var menubarAutoVisibilityEdge = props.globals.initNode( "/sim/menubar/autovisibility/edge-size", 5, "INT" ); var menubarVisibility = props.globals.initNode( "/sim/menubar/visibility", 0, "BOOL" ); var currentMenubarVisibility = menubarVisibility.getValue(); @@ -1525,12 +1527,19 @@ setlistener( "/sim/menubar/autovisibility/enabled", func(n) { menubarVisibility.setBoolValue( 1 ); }, 1, 0 ); + menubarAutoVisibilityListener = setlistener( mouseMode.getPath(), func(n) { + if( n.getValue() != 0 ) { + menubarVisibility.setBoolValue( 0 ); + } + }, 1, 0 ); } # do not listen to the mouse position if this feature is enabled if( n.getValue() == 0 and menubarAutoVisibilityListener != nil ) { removelistener( menubarAutoVisibilityListener ); + removelistener( menubarAutoVisibilityMouseModeListener ); menubarAutoVisibilityListener = nil; + menubarAutoVisibilityMouseModeListener = nil; menubarVisibility.setBoolValue(currentMenubarVisibility); } }, 1, 0);