#----------------------------------------------------------
#Function for the event procedure
#----------------------------------------------------------
import mpfc
from newwin000 import newvlab_001

def numbtnep(object):
	#do something...
	# Get the number of button from WSNlabelString
	val = object.getProperty("labelString").getCharPtr()
	
	# Store the number to the indicator label.
	# Check the last input is the number.
	numpushed = newvlab_001.getVariantData("num-input").getInt()
	
	# Check the dot mode (floating mode).
	dotpushed = newvlab_001.getVariantData("dot-input").getInt()
	
	# Get the last indicated string.
	val2 = newvlab_001.getProperty("labelString").getCharPtr()
	
	# Cancel the input when the string is too long.
	if len(val2) > 13:
		return
	
	# The input is number, add it to indicator.
	if numpushed == True:
		value = val2
		if value == "0":
			if dotpushed == True:
				tmp = "0." + val
			else:
				tmp = val			
			newvlab_001.setProperty("labelString",str(tmp))

		else:
			tmp = val2;
			if dotpushed == True:
				if tmp.find(".") == -1:
					tmp = tmp + "."
			tmp = tmp + val
			newvlab_001.setProperty("labelString",str(tmp))
	else:
		tmp = ""
		if dotpushed == True:
			tmp = "0."
		
		tmp = tmp + val;
		newvlab_001.setProperty("labelString",str(tmp))

	# Store that the number button is pushed.
	newvlab_001.setVariantData("num-input",True)
	
	return
mpfc.WSGFfunctionRegister("numbtnep",numbtnep)
