Permalink
Browse files

Add double clicks to click demo

  • Loading branch information...
1 parent dad46c8 commit 2c853ce162d2b1206fda86eaa8ca0291999ad291 @davidaurelio davidaurelio committed Feb 28, 2013
Showing with 14 additions and 7 deletions.
  1. +14 −7 example/library/movies/event-click.js
@@ -1,23 +1,30 @@
/**
* Path w/ events.
*/
-var rectPath = bonsai.Path.rect(150, 150, 150, 150).attr({fillColor: 'red'});
+var rectPath = bonsai.Path.rect(150, 150, 150, 150).attr({
+ fillColor: 'red',
+ strokeColor: 'red',
+ strokeWidth: 10
+});
var colors = [
'green',
'blue',
'yellow',
'red'
];
-var index = 0;
-
+var numColors = colors.length;
stage.addChild(rectPath);
rectPath.on('click', function(data){
- counts.click++;
+ var index = counts.click += 1;
+ updateCountsText();
+ rectPath.attr({fillColor: colors[index % numColors]});
+});
+rectPath.on('dblclick', function() {
+ var index = counts.dblclick += 1;
updateCountsText();
- if (++index == colors.length) index = 0;
- rectPath.attr({fillColor: colors[index]});
+ rectPath.attr({strokeColor: colors[index % numColors]});
});
rectPath.on('pointerdown', function(data){
counts.pointerdown++;
@@ -31,7 +38,7 @@ rectPath.on('pointerup', function(data){
var t = new Text().attr({x: 100, y: 10});
t.addTo(stage);
var counts = {
- click: 0, pointerdown: 0, pointerup: 0
+ click: 0, dblclick: 0, pointerdown: 0, pointerup: 0
};

0 comments on commit 2c853ce

Please sign in to comment.