Creating a debug menu - best practice

Hi - I’m trying to create a debug menu (in a container) that hides/shows on keypress. The debug menu contains things that cook every frame, but setting the display flag of my container and then disabling cooking does not properly hide the container.

Is this the proper approach to a debug menu? Is disabling cooking on hide necessary?
Sample project attached, and script for a chopexecute below:


debugMenu = op('container1')
def onOffToOn(channel, sampleIndex, val, prev):
	current = debugMenu.par.display
	set = 0
	cook = False
	if current == 0: 
		set = 1
		cook = True
	else:
		set = 0
	debugMenu.par.display = set
	#comment out line below to see display flag working as expected
	debugMenu.allowCooking = cook
	
	return

debugMenuSample.1.toe (4.64 KB)

Seems like an issue where because it’s happening on the same frame, the display doesn’t actually get turned off before it stops cooking. A quick fix is to delay the cooking portion by a few frames (i quickly tested with 3 frames and it worked fine).

You can add something like

run("op('{}').allowCooking = False".format(debugMenu.path), delayFrames = 3)

Instead of the current last line

Thanks elburz! Is that delay blocking / could it cause grief? And does Touch actually need you to disable cooking or does it know not to cook if display is disabled?