summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/eventhandling/scribble.js
blob: 95fafe7c8958c64b4b1272f65818f0639d10bd07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env kjscmd

//
// The standard 'scribble' application coded using kjsembed
//


var scribble = new TQWidget(this);
scribble.line=false;
var x=0;
var y=0;

scribble.mousePressEvent = function(ev)
{
  if ( ev.button == 2 ) {
    this.drawText(ev.x,ev.y,'KJSEmbed!');
  }
  else {
    x = ev.x;
    y = ev.y;
    line=true;
  }
}

scribble.mouseReleaseEvent = function(ev)
{
  if ( line )
    this.drawLine(x,y,ev.x,ev.y);
  line = false;
}

scribble.show();
application.exec();