hackathon-dev #1
@ -23,7 +23,22 @@ def point_in_rect(rect, x, y):
 | 
			
		||||
	return (x >= rect[0]) and (x < rect[2]) and (y >= rect[1]) and (y < rect[3])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# --- Message handlers ---
 | 
			
		||||
 | 
			
		||||
def on_touchclick(x, y):
 | 
			
		||||
	print("Click at {0},{1}".format(x, y))
 | 
			
		||||
	if point_in_rect(cmd1_rect, x, y):
 | 
			
		||||
		print("Click command 1")
 | 
			
		||||
	elif point_in_rect(cmd2_rect, x, y):
 | 
			
		||||
		print("Click command 2")
 | 
			
		||||
	elif point_in_rect(cmd3_rect, x, y):
 | 
			
		||||
		print("Click command 3")
 | 
			
		||||
	elif point_in_rect(cmd4_rect, x, y):
 | 
			
		||||
		print("Click command 4")
 | 
			
		||||
 | 
			
		||||
def on_button_click(button):
 | 
			
		||||
	if button == 4:			# Button 4 = Exit app
 | 
			
		||||
		upiwin.post_quit_message(0)
 | 
			
		||||
 | 
			
		||||
# --- Initialize and start message loop ---
 | 
			
		||||
 | 
			
		||||
@ -38,15 +53,6 @@ hdc.rectangle(cmd4_rect[0], cmd4_rect[1], cmd4_rect[2], cmd4_rect[3])
 | 
			
		||||
msg = {}
 | 
			
		||||
while upiwin.get_message(msg):
 | 
			
		||||
	if msg['message'] == upiwin.WM_TOUCHCLICK:
 | 
			
		||||
		print("Click at {0},{1}".format(msg['attrs'][0], msg['attrs'][1])
 | 
			
		||||
		if point_in_rect(cmd1_rect, msg['attrs'][0], msg['attrs'][1])):
 | 
			
		||||
			print("Click command 1")
 | 
			
		||||
		elif point_in_rect(cmd2_rect, msg['attrs'][0], msg['attrs'][1])):
 | 
			
		||||
			print("Click command 2")
 | 
			
		||||
		elif point_in_rect(cmd3_rect, msg['attrs'][0], msg['attrs'][1])):
 | 
			
		||||
			print("Click command 3")
 | 
			
		||||
		elif point_in_rect(cmd4_rect, msg['attrs'][0], msg['attrs'][1])):
 | 
			
		||||
			print("Click command 4")
 | 
			
		||||
		on_touchclick(msg['attrs'][0], msg['attrs'][1])
 | 
			
		||||
	elif msg['message'] == upiwin.WM_HWBUTTONCLICK:
 | 
			
		||||
		if msg['attrs'][0] == 4:			# Button 4 = Exit app
 | 
			
		||||
			upiwin.post_quit_message(0)
 | 
			
		||||
		on_button_click(msg['attrs'][0])
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user