All pastes #812134 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-11 15:11 UTC
rendered paste body
set canvas [lcdui.canvas -eventhandler hiddenCanvasEvents]

# this gives errors like: http://pastebin.ca/812098
proc hiddenCanvasEvents {src ev} {
    global canvas
    set graphics [$canvas graphics]
    $graphics color red

	if {eq [$ev cget -reason] 5} {
		puts foo
	}
}

# this doesnt give errors
#proc hiddenCanvasEvents {src ev} {
#	global sg graphics image
#	$image circle 50 [list 50 100]
#	$sg render $graphics $image
#}


set cmd_exit [lcdui.command -label Exit -longlabel Back -priority 1 -type cancel]
proc handleEvents {cmd_exit cmd from} {
	if {eq $cmd_exit $cmd} {
		global returnval
		set returnval 0
		tnotify returnval
	}
}

$canvas addcommand $cmd_exit
$canvas configure -commandaction [list handleEvents $cmd_exit]
$canvas setcurrent

twait returnval
set returnval