Create List from Buttons Pressed

Hype has a global object you can use to add data.

hypeDocument.customData

You can give each cord a data attribute in the identity inspector defining its value.


When the button is clicked it goes to your how to scene & runs a function to store the cord in

hypeDocument.customData.

We also set up for printing later on.

Screenshot 2021-08-16 at 21.50.54

	///hypeDocument.customData.store check to see if it has been used already.
	if( typeof hypeDocument.customData.store == "undefined"){
	
	/// not used yet so we define it to a blank string
	hypeDocument.customData.store = ""
	
	
	/// While we are in here and this section will only run once , we may as well set up the print listeners
	window.addEventListener("beforeprint", function(event) { 
	
	
	/// BEFORE Printing - find all elements with the class name noPrint and hide them
	var noprintElements = Array.from(document.querySelectorAll('.noPrint'))
 
		//noprintElements.forEach(thisElement => thisElement.style.style.visibility = "hidden");
	
				for (let i = 0; i < noprintElements.length; i++) { 
 				noprintElements[i].style.visibility = "hidden"

				};
			});
			
			
		/// AFTER Printing - find all elements with the class name noPrint and show them again
	window.addEventListener("afterprint", function(event) { 
	
	var noprintElements = Array.from(document.querySelectorAll('.noPrint'))
	
				for (let i = 0; i < noprintElements.length; i++) { 
 					noprintElements[i].style.visibility = "visible"

				};


			});
			
	}
	
	
	/// this will always run.
	/// append a cord to the list
	
	hypeDocument.customData.store +=  element.dataset.cord + " "

We have a done button & Back button ( in a persistent symbol)

When the done button is clicked it will take you to the Print scene, which has a JS Function Action on scene load which sets up the print text.

hypeDocument.getElementById('printCords').innerHTML = hypeDocument.customData.store

The Print scene has the back button symbol and a Print button .
These will be given the noPrint class name in the identity inspector.

When we hit print, they will hide and later show again according to the listener functions.

The print button simpley calls
window.print()

In its function


storeAndPrint.hype.zip (59.9 KB)


for longer term storage lookup LocalStorage as @Photics suggests.

2 Likes