summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/eventhandling/scribble.js
blob: 0ffcdb070db4ca5bb4c00e718a6390cb5d1ae572 (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 QWidget(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();