extends VBoxContainer

var referances = []

func setUp():
		# load scene
	var stockTemplate = preload("res://Scenes/eachStock.tscn")
	
	for eachStock in get_parent().stocks:
		# make a copy and push to screen container
		var newBtn = stockTemplate.instantiate()
		newBtn.text = eachStock.title
		
		newBtn.setInfo(eachStock)
		add_child(newBtn)
		referances.append(newBtn)
		
	for child in get_children():
		# assign an action to it
		if child is Button:
			
			child.pressed.connect(func(): callBack(child))
			
	# call outer function to get referances passed through
	get_parent().getReferances(referances)
	# display the first child's data by default
	callBack(get_child(0))
	
	pass
	
func callBack(node):
	get_node("/root/Control/CanvasLayer/StockPage").setInfo(node.getInfo())
	pass
