guess I need to declare certain things as global

This commit is contained in:
Amy Bowersox 2019-12-11 12:50:10 -07:00
parent fee3619ee1
commit 2c0a1374d9

View File

@ -31,13 +31,14 @@ origin_y = 0
current_x = 0 current_x = 0
current_y = 0 current_y = 0
def rubberband_rectangle(x, y, down, up) def rubberband_rectangle(x, y, down, up):
global current_x, current_y
hdc.text_color = YELLOW hdc.text_color = YELLOW
hdc.rop2 = upiwin.R2_XORPEN hdc.rop2 = upiwin.R2_XORPEN
if not down: if not down:
hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y)) hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y))
current_x = x; current_x = x
current_y = y; current_y = y
if not up: if not up:
hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y)) hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y))
@ -49,9 +50,10 @@ def rubberband_rectangle(x, y, down, up)
# --- Message handlers --- # --- Message handlers ---
def on_touchdown(x, y): def on_touchdown(x, y):
global origin_x, origin_y
if point_in_rect(drawing_rect, x, y): if point_in_rect(drawing_rect, x, y):
origin_x = x; origin_x = x
origin_y = y; origin_y = y
rubberband_rectangle(x, y, True, False) rubberband_rectangle(x, y, True, False)
def on_touchmove(x, y): def on_touchmove(x, y):