Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (16 sloc) 575 Bytes
An.object().from(Widget).named('Key').has('letter','A').has('width',48).has('height',48).has('x',100).has('y',100).has('font','24 Arial').
does('draw', function() {
Screen.save().as(this).blue().frame().
this.font.use()
Screen.at(this.x() + this.width()/2 - this.font().size()/4, this.y() + this.height()/2 + this.font().size()/4).print(this.letter())
return this
}).
does('down', function(E) {
if (!E.on(this)) return;
E.has('key',this.letter())
Keyboard.dispatch('press',E)
}).
does('up', function(E) {
E.has('key',this.letter())
Keyboard.dispatch('release',E)
})