Altitude Hold Toggle not working - K:AP_ALT_HOLD

@FlyingRaccoon

Hi Sylvain,

I’m trying to assign a basic Altitude Hold On | Off function to a button (node) that has no animation, just a simple left-click once to capture and hold the currently flown altitude, left-click once again to turn it all off. This is the code I have:

<Component ID="NODE_ID_ALT_HOLD" Node="NODE_ID_ALT_HOLD">
<UseTemplate Name = "ASOBO_GT_Interaction_LeftSingle_Code">
<LEFT_SINGLE_CODE>
(A:AUTOPILOT MASTER, Bool) 1 ==
(A:AUTOPILOT ALTITUDE LOCK, Bool) 0 ==
and if{ (&gt;K:AP_ATT_HOLD_OFF) (&gt;K:AP_VS_OFF) (&gt;K:AP_ALT_HOLD) }	
				
els{ 

(A:AUTOPILOT MASTER, Bool) 1 ==
(A:AUTOPILOT ALTITUDE LOCK, Bool) 1 ==
and if{ (&gt;K:AP_ALT_HOLD_OFF) (&gt;K:AP_ATT_HOLD_ON) }
}
 </LEFT_SINGLE_CODE>
<CURSOR>Hand</CURSOR>
<TOOLTIP_TITLE></TOOLTIP_TITLE>
<TOOLTIPID>%((A:AUTOPILOT ALTITUDE LOCK, Bool))%{if} GP Altitude Hold: On %{else} GP Altitude Hold: Off %{end}</TOOLTIPID>			
</UseTemplate>
</Component>

While the above code will correctly capture the currently flown altitude and engage Altitude Hold Mode, any subsequent left-click will not turn off the Altitude Hold Mode once it’s on. I have tried using the AP_ALT_HOLD toggle again instead of AP_ALT_HOLD_OFF, nothing changes.

If I use (>K:AP_ALT_HOLD_ON) instead of (>K:AP_ALT_HOLD) then the autopilot seems to sort of reliably capture the currently flow altitude the first time around, and can also be turned off by a 2nd mouse-click, but subsequent use for altitude capture and hold then seems unreliable.

Since the SDK states that K:AP_ALT_HOLD toggles the altitude hold mode, why is this not being turned off by the 2nd left mouse-click?

Why are both K:AP_ALT_HOLD and K:AP_ALT_HOLD_OFF not turning off the active Altitude Hold Mode if this has been engaged by K:AP_ALT_HOLD?

Thanks in advance for any insight and assistance,

Jerome